Let's say I have an existing database with the following 3 tables:
Table1:
(PK)T1ID1
(PK)T1ID2
Table2:
(PK)T2ID1
Table3:
(FK)T1ID1
(FK)T1ID2
(FK)T2ID1
(Where the 3 keys come from the tables above)
My question is: How do I map Table3 with Fluent NHibernate?
What is confusing to me is what to do about the fact that its composite keys come from 2 different tables.
I have the following for the mappings for tables 1 and 2:
public class Table1
{
public virtual long T1ID1 { get; set; }
public virtual long T1ID2 { get; set; }
}
public class Table2
{
public virtual long T2ID1 { get; set; }
}
public class Table1Map
{
public Table1Map()
{
Table("Table1");
CompositeId()
.KeyProperty(x => x.T1ID1, "T1ID1")
.KeyProperty(x => x.T1ID2, "T1ID2");
}
}
public class Table2Map
{
public Table2Map()
{
Table("Table2");
Id(x => x.T2ID1, "T2ID1");
}
}