I have some questions about creating FKs with the Fluent API
For example: I have the class
Cliente
andEndereco
, and the client can have more than 1 address, but the address can only belong to 1 client, so I would like to create a new table for this, because this classEndereco
will be used for other classes that can also have address. (New classRelacaoClienteEndereco
).
public class Endereco : EntityBase
{
public Endereco()
{
}
public string CEP { get; set; }
public string Logradouro { get; set; }
public string Numero { get; set; }
public string Complemento { get; set; }
public string Bairro { get; set; }
public string Estado { get; set; }
public string Cidade { get; set; }
public TipoEndereco TipoEndereco { get; set; }
public bool EnderecoCorrespondencia { get; set; }
}
public class Cliente
{
public int ID { get; set; }
public string NomeCompleto { get; set; }
public virtual ICollection<Domain.Cadastros.Endereco> Enderecos { get; set; }
}
How to do FK in this case with the Fluent API?