Is there any way to get the metadata informations for the relationships?
public partial class Contact
{
public Contact()
{
this.Addresses = new HashSet<Address>();
}
public int Id { get; set; }
public virtual ICollection<Address> Addresses { get; set; }
}
public partial class Address
{
public int Id { get; set; }
public int? ContactId { get; set; }
}
How the entity framework knows, that the ContactId is a foreign key?
There is no metadata, it’s done by conventions, in the blog post below you can find some more info:
Conventions for Code First
It’s possible to add metadata by decorating the properties with attributes, but that’s not necessary.