如何在abpfeature表中添加和使用新列并在样板中访问它? [英] How can I add and use new column in abpfeature table and access it in boilerplate?

查看:74
本文介绍了如何在abpfeature表中添加和使用新列并在样板中访问它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在样板上使用asp.net零构建,我想扩展特征表,但是我无法像创建的其他普通表那样访问特征表.有人可以帮忙吗?

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?

推荐答案

我遇到了另一个表 AuditLogs 的问题,最后我设法使用EF Core功能解决了该问题.您可以在此处

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

解决方案基于EF Core中的继承概念.基本上,您可以创建一个新类,即" ExtendedFeature "衍生自 AbpFeature .然后,您可以在项目的主上下文中添加新的 DbSet 并运行所需的迁移.这将更新您的主表 AbpFeature ,并添加新列以及将通过EF插入过程自动设置的 Discriminator 列.

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.

如果您创建一个新的 ExtendedFeature 实例,则 discriminator 列将设置为 discriminator ,否则它将设置为 Feature.这将使您的记录在数据库中与众不同.

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.

这篇关于如何在abpfeature表中添加和使用新列并在样板中访问它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆