Just wanted to know more about RelatedTo
attribute and I found out it has been replaced by ForeignKey
and InverseProperty
attributes i
ForeignKey
attribute pairs FK property with navigation property. It can be placed either on FK property or navigation property. It is equivalent of HasForeignKey
fluent mapping.
public class MyEntity
{
public int Id { get; set; }
[ForeignKey("Navigation")]
public virtual int NavigationFK { get; set; }
public virtual OtherEntity Navigation { get; set; }
}
InverseProperty
is used for defining self referencing relation and pairing navigation properties on both ends. Check this question for sample.