【发布时间】:2015-06-17 13:57:30
【问题描述】:
在我的项目中,我有:
public class BaseEntity {
[Key]
public int Id {get; set; }
}
然后我必须定义 10+ POCO 类来定义我的数据库中的表:
public class MyTable : BaseEntity {
//define properties here
}
当然,因为 MyTable 继承自 BaseEntity 我得到了 Discriminator 字段。我想去掉 Discriminator 字段,因为我不需要创建表 BaseEntity,也不需要在我的数据库中实现某种继承。
有可能吗?
【问题讨论】:
-
我怀疑我错过了这里的重点,但为什么不直接放弃 BaseEntity 和继承模型呢?
-
@DavidArno 我试图在创建表键时保持某种一致性,我的所有表都将以 Id (int) 作为主键创建。是的,如果没有办法,我可以摆脱它......
标签: c# ef-code-first entity-framework-6