【发布时间】:2012-02-18 09:02:46
【问题描述】:
我想在使用 EF 4.x 时实现层超类型模式((PoEAA)。
假设我有一个名为 Entity 的层超类型类,从该类继承了两个类 Teacher 和 Student。
Person类是这样定义的
class Entity
{
public int Id {get;set;}
}
还有这样的老师和学生
class Teacher : Entity
{
publix string Name {get;set;}
}
class Student : Entity
{
public int Age {get;set;}
}
如何配置 EF 4.x 以便在我的数据库中只有两个对应于 Teacher 和 Student 的表?我尝试使用 TPC 继承策略来映射此结构,但它不适合,它为每个具体类创建三个表..
使用 NHibernate,这种情况很常见并且处理得很好,我的意思是如果我只为 Person 和 Student 创建映射,数据库将只有两个表,我不必显式地实现任何继承。
感谢大家的建议
丽安娜
【问题讨论】: