问题
I'm using asp.net zero build on boilerplate and I want to extend my table of feature, but I couldn't access feature table like other normal tables which I've created. Can anyone help?
回答1:
I was facing your problem with another table AuditLogs
, and I finally managed to solve it using EF Core features. You can find my issue and its solution here
The solution is lying on the concept of inheritance in EF Core. Basically, you can create a new class namely "ExtendedFeature" derived from AbpFeature
. Then you can add a new DbSet
in the main context of your project and run the required migration. This will update your main table AbpFeature
and add the new columns as well as the Discriminator
columns which will be set automatically through the EF insert procedure.
If you create a new instance of ExtendedFeature
the discriminator
column will be set with discriminator otherwise it will be set with Feature. This will make your records distinguishable in the database.
For further information you can read this article.
来源:https://stackoverflow.com/questions/59982180/how-can-i-add-and-use-new-column-in-abpfeature-table-and-access-it-in-boilerplat