So have an issue coming up with mapping where we have two classes
public class Customer
{
public int Id;
public CustomerAddress StatementAddress
public bool AlwaysTrue => true;
public string Code;
}
public class CustomerAddress
{
public int Id;
public bool ForStatement;
public string _CustomerCode
}
We than have a mapping set up like this:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Customer>()
.HasOne(s => s.StatementAddress)
.WithMany()
.HasPrincipalKey(x=> new {x._CustomerCode, x.ForStatement})
.HasForeignKey(s => new { s.Code, s.AlwaysTrue});
}
This is however causing an issue, as it seems to be on the database looking for a column of StatementAddress_CustomerCode and StatementAddress_ForStatement within the Customer table, which clearly are not things that exist - why isnt it looking for the Code table and simply passing through True for the AlwaysTrue?
I would have thought the way its defining keys would just Use the Code and Alwaystrue value, but seems to be looking for two columns made up of a combination of the Property name, appended with the property name from the other class =/