Entity framework 在实体框架中使用继承?
我有两张DB格式的桌子:Foo和Bar 使用实体框架,我想创建一个基本实体,它将包含两个表都具有的属性 例如,Foo有Id、CreateDate、FooValue列,Bar有Id、CreateDate、BarValue列Entity framework 在实体框架中使用继承?,entity-framework,inheritance,Entity Framework,Inheritance,我有两张DB格式的桌子:Foo和Bar 使用实体框架,我想创建一个基本实体,它将包含两个表都具有的属性 例如,Foo有Id、CreateDate、FooValue列,Bar有Id、CreateDate、BarValue列 所以BaseEntity应该具有Id和CreateDate属性 Foo应该继承BaseEntity并具有FooValue Bar应继承BaseEntity并具有BarValue 如何将属性映射到数据库中的表?我假设您需要-下面是一个示例。您也可以考虑修改表并使用每种类型的表
- 所以BaseEntity应该具有Id和CreateDate属性
- Foo应该继承BaseEntity并具有FooValue
- Bar应继承BaseEntity并具有BarValue
CreationDate
之类的列来说是一个错误的决定,因为您将得到一个包含所有表的创建日期的表