我正在使用遗留数据库上的EF进行应用程序。在数据库中有两个我关心的表。 (在C#形式)的结构是这样的:将具有不同主键的两个表映射到一个实体
public class Employee
{
public int employeeID {get; set;} //primary key
public string name {get; set;}
...//other attributes from this table (not relevant)
}
public class EmployeeProfile
{
public int profileID {get; set;} //primary key
public int employeeID {get; set;}
public string favoritemovie {get; set;}
...//other attributes from this table (not relevant)
}
有一个1 - 与数据库EmployeeProfile
和Employee
1的关系。在我的应用程序中,我想创建一个组合实体,如下所示:
public class Employee
{
public int employeeID {get; set;}
public string name {get; set;} //taken from Employee Table
public string favoritemovie { get; set; } //taken from EmployeeProfile table
}
我该怎么做?我听说过实体拆分,但这要求表具有相同的主键。