我希望在我的模型中有一个人物实体。没有相应的表和鉴别器。我只是想将其作为其他一些实体共享的普通基类(我想定义一个具有公共功能的public partial class Person
)。
例如,我想要有:
// this class has no corresponding table in the DB
public partial abstract class Person
{
public int Id {get; set;}
public string FirstName {get; set;}
public string LastName {get; set;}
public string DisplayName { get { return string.Format("{0}, {1}", LastName, FirstName); } }
}
// this corresponds to dbo.Users
public partial class User : Person
{
}
// this corresponds to dbo.Contacts
public partial class Contact : Person
{
}
因此,我创建了一个抽象实体 Person,将其设置为用户和联系人实体的基类,然后添加了我的属性,并设置了 dbo.Users 和 dbo.Contacts 的 PK Id、FirstName 和 LastName 属性的映射。
但是我遇到了错误:
3032: Problem in mapping fragments starting at lines 2109
..... are being mapped to the same rows in table .... Mapping conditions can be used to distinguish the rows that these types are mapped to.
我该如何让这个工作起来?