0
I’m trying to create a Primary key composed, until everything well. With this I need to make a Foreign key composed.
I have more or less the following scenario (it is a hypothetical scenario but reflects what I need and my mistake):
public class Keys {
[Key, Column(Order = 0)]
public int Key_1 { get; set; }
[Key, Column(Order = 1)]
public int Key_2 { get; set; }
// order is important here as defined in "KeyAuthorities" table
[ForeignKey("KeyAuthorities", Column(Order = 0)]
public int KeyAuthorities_Key_1 { get; set; }
[ForeignKey("KeyAuthorities", Column(Order = 1)]
public int KeyAuthorities_Key_2 { get; set; }
}
public class KeyAuthorities {
[Key, Column(Order = 0)]
public int KeyAuthorities_Key_1 { get; set; }
[Key, Column(Order = 1)]
public int KeyAuthorities_Key_2 { get; set; }
}
The Foreignkeyattribute on Property 'Keyauthorities' on type 'Portaladmcc.Models.Keys' is not Valid. The Foreign key name 'Keyauthorities' was not found on the dependent type 'Portaladmcc.Models.Keys'. The Name value should be a comma separated list of Foreign key Property Names.
What that mistake means?
It seems that you missed closing the Foreignkey parentheses. The error indicates that you do not have the "Keyauthorities" browsing property in the "Key" class"
– Pagotti
What that means basically?
– gabrielfalieri
I put an answer. I don’t know if the second way really works. I don’t use model with compound FK.
– Pagotti