How do I map a navigation property when there is no key of its parent in it?
I mean
There is a class Contract. This is a contract of sale of a product and needs a product to exists. TB_Contract contains ProductId. The Product exists without a contract and there isn't a ContractId on TB_product.
In some cases the product can be in more than one contract, that's why it has been modeled as a many to one in bd. But in our classes it must be one-to-one
public class Contract
{
...
public Product Product { get; set; }
...
}
public class Product
{
...
public Contract Contract { get; set; }
...
}
table tb_Contract
(
idContract,
idProduct
)
table tb_Product
(
idProduct,
description,
)
I want my class Product have the contract which it's linked to, if there is one.
I'm using code first. How to I map it on EF6?