I have a relationship between Address and Academy where 1 address has 1 gym, and 1 gym has 1 address.
Academy Class:
public class Academia
{
[Key]
public int AcademiaID { get; set; }
...
//relacionamentos
public int EnderecoID { get; set; }
public virtual Endereco Endereco { get; set; }
}
Class Address
public class Endereco
{
[Key]
public int EnderecoID { get; set; }
...
public int LocalID { get; set; }
public virtual Local Local { get; set; }
}
When I do Enable-Migration
I get the following message:
Unable to determine the main end of an association between the types 'Academia.Models.Endereco' and 'Academia.Models.Academia'. The main end of this association must be explicitly configured using either the fluent relationship API or data annotations.
As I understand it, the entity does not know how to define who is the principal between the two classes