I have two POCO classes:
Order Class:
public class Order
{
public int Id { get; set; }
public int? QuotationId { get; set; }
public virtual Quotation Quotation { get; set; }
....
}
Quotation Class:
public class Quotation
{
public int Id { get; set; }
public virtual Order Order { get; set; }
....
}
- Each
Ordermay be made from one or zero quotation, and - each quotation may cause an order.
So I have an "one or zero" to "one or zero" relation, how can I implement this, in EF Code first by Fluent API?
By changing pocos to:
and using these mapping files:
we will have this DB(that means 0..1-0..1):
with special thanks to (Vahid Nasiri)