I have two tables. Invoice and Plant.
public partial class Invoice
{
[Key]
public int InvoiceId{ get; set;}
[Foreignkey("Site"]
public int SiteId{ get; set; }
//There is no field in this table that gives me the corporateId
[InverseProperty("Invoices")]
public Site Site{ get; set; }
}
public partial class Sites
{
[Column(Order = 0)]
[Key]
public int SiteId{ get; set;}
[Column(Order = 1)]
[Key]
public int CorporateId{ get; set; }
[InverseProperty("Site")]
public ICollection<Invoices> Invoices{ get; set; }
}
I want to use Context.Invoices.Include(s => s.Site)
instead of a join. I know which CorportageId I need. I would like to set it the same for each invoices. I tried by adding a field in Invoices but EF doen't map it to the right key. Any idea?