Database build error:
One or more validation errors were detected during model generation:
Key_Authorities_Source_Key_Authorities_Target: : The number of properties in the Dependent and Principal Roles in a relationship constraint must be identical.
Key Class:
[Table("Keys")]
public class Key
{
[Key, Column(Order = 0)]
public int Id { get; set; }
[Key, Column(Order = 1)]
public int OwnedByFId { get; set; }
[Key, Column(Order = 2)]
public int OwnedByUId { get; set; }
public string Name { get; set; }
public string Description { get; set; }
[ForeignKey("Id"), Column(Order = 1)]
public virtual ICollection<KeyAuthorities> Authorities { get; set; }
}
Key Authorities Class:
[Table("Key_Auths")]
public class KeyAuthorities
{
[Key, Column(Order = 0)]
public int Id { get; set; }
[Key, Column(Order = 1)]
public int KeyId { get; set; }
public int DoorId { get; set; }
public int VehicleId { get; set; }
public int GateId { get; set; }
}
Why doesn't this set this foreign key?
ICollection
(non-generic) in a navigation property.