在我的项目中我有:
public class BaseEntity {
[Key]
public int Id {get; set; }
}
然后我必须定义 10 多个 POCO 类来定义数据库中的表:
public class MyTable : BaseEntity {
//define properties here
}
当然,因为MyTable
继承自BaseEntity
我明白了鉴别器 https://stackoverflow.com/questions/7393788/entity-framework-code-first-creates-discriminator-column场地。我想摆脱Discriminator
字段,因为我不需要表BaseEntity
要创建,我也不需要在我的数据库中实现某种继承。
是否可以?
有几个选择:
- Make
BaseEntity
abstract
- Use
modelBuilder.Ignore<BaseEntity>()
in yourDbContext.OnModelCreating
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)