レガシー データベースで EF を使用してアプリケーションを作成しています。データベースには、私が関心を持っている 2 つのテーブルがあります。構造 (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 対1 の関係にEmployeeProfile
ありEmployee
ます。私のアプリケーションでは、次のような複合エンティティを作成したいと考えています。
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
}
これどうやってするの?エンティティの分割について聞いたことがありますが、それにはテーブルが同じ主キーを持つ必要があります。