Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 811
Adeel Siddiqui Avatar asked Jan 30 '20 08:01

Adeel Siddiqui


1 Answers

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.

like image 191
Mahyar Mottaghi Zadeh Avatar answered Oct 20 '22 10:10

Mahyar Mottaghi Zadeh