Hi guys I have a question about EF Fluent API (Code First :P). In my model I have
public class TABLE_A
{
public virtual long Id {get; set;}
....
public virtual TABLE_B MyTableBRef {get; set;}
}
public class TABLE_B
{
public virtual long Id {get; set;}
....
public virtual TABLE_A MyTableARef {get; set;}
}
How am I supposed to map a 0..1 to 0..1 relationship?
In the database on TABLE_B I have a column (FK) that references the PK of TABLE_A.
It is not possible to have navigational properties on both sides if you are using a column other than the PK of
TABLE_B.If the PK of
TABLE_Bis also a FK toTABLE_Athen you can use shared PK mapping with navigational properties on both sides.Edit:
You can use Shared PK mapping as follows
The
IdofTABLE_Bis also an FK toTABLE_A.