How can I add and use new column in abpfeature table and access it in boilerplate?

情到浓时终转凉″ 提交于 2021-02-20 09:43:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!