abp icon indicating copy to clipboard operation
abp copied to clipboard

TablePrefix Not Being Used

Open wayneboyles opened this issue 7 years ago • 4 comments

I have a test project in which my DbContext's OnModelCreating method configures the table prefix for each module:

modelBuilder.ConfigureSettingManagement("MyPrefix");

When I create a Migration the table is created as MyPrefixSettings as expected. However, when running the project I get an error that AbpSettings is an invalid object - which it is since I've changed the prefix.

Should I be defining the prefix elsewhere in the code? Is there a global setting somewhere to override the TablePrefix for all Abp Entities like in the previous version?

Thanks.

wayneboyles avatar Mar 25 '19 17:03 wayneboyles

I can reproduce the problem you mentioned.

https://github.com/abpframework/abp/blob/287f71d805cef27a221e6eead02fec59b6e62187/modules/setting-management/src/Volo.Abp.SettingManagement.EntityFrameworkCore/Volo/Abp/SettingManagement/EntityFrameworkCore/SettingManagementDbContext.cs#L22-L27

It seems to be overriding the configuration of the custom table prefix.

maliming avatar Mar 26 '19 02:03 maliming

Try to set SettingManagementDbContext.TablePrefix property in your ConfigureServices method. It is not constant, it is static.

hikalkan avatar Mar 26 '19 08:03 hikalkan

Try to set SettingManagementDbContext.TablePrefix property in your ConfigureServices method. It is not constant, it is static.

This works. I updated my code to use SettingManagementDbContext.TablePrefix = "MyPrefix" and it no longer fails to find the table so that's honoring the value correctly. I did the same for other modules such as PermissionManagementDbContext.TablePrefix and seems to be working correctly.

wayneboyles avatar Mar 26 '19 14:03 wayneboyles

I'm closing because this is by design :)

hikalkan avatar Mar 26 '19 14:03 hikalkan