Is it posible to define a compound foreign primary key without defining scalar properties?
public class A
{
public virtual int AID { get; set; }
}
public class B
{
public virtual int BID { get; set; }
}
public class CompoundKeyClass
{
public virtual A AObject { get; set; }
public virtual B BObject { get; set; }
}
How can I make properties AObject and BObject the compound PK of CompoundKeyClass without defining the scalar ID properties of for A and B types using the FluentAPI?
You can’t. Both
AIDandBIDmust be in yourCompoundKeyClassmapped as complex primary key and each of them must be mapped as foreign key to related table.