明確にするために、1 つのオブジェクト全体とそのすべてのプロパティを、基本的に同じテーブルの異なるコピーにマップしようとしています。私の検索は、オブジェクトのプロパティを複数のテーブルに分割する方法を示していますが、それは私が達成しようとしていることではありません。
ここに私のオブジェクトモデルがあります(取り除かれています):
class Customer
{
public Guid CustomerGuid { get; set; }
public string Name { get; set; }
public Address Address { get; set; }
}
class Address
{
public Guid AddressGuid { get; set; }
public string Line1 { get; set; }
public string State { get; set; }
}
class Application
{
public Guid ApplicationGuid { get; set; }
public Address Address { get; set; }
public DateTime SubmittedDate { get; set; }
}
問題は、Address をコンポーネントのように動作させる必要があることですが、CustomerAddress と ApplicationAddress の 2 つの別個のテーブルに保存する必要があります。
table Customer
(
CustomerGuid
Name
)
table Application
(
ApplicationGuid
SubmittedDate
)
table CustomerAddress
(
CustomerGuid
Line1
State
)
table ApplicationAddress
(
ApplicationGuid
Line1
State
)
1 対 1 (HasOne) を使用して Customer から CustomerAddress へのマッピングの 1 つを達成できることはわかっていますが、Application から ApplicationAddress で同じことを行うにはどうすればよいでしょうか?