我正在使用遺留數據庫上的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
}
我該怎麼做?我聽說過實體拆分,但這要求表具有相同的主鍵。