I have an Address class that is Complex Type . Can it have a state property that is an Entity Type ?
Class Code:
public class Endereco
{
...
public string Logradouro { get; set; }
public Estado Estado { get; set; }
}
public class Estado
{
public int Id { get; set; }
public string Nome { get; set; }
}
Class Mapping:
public class EnderecoConfiguracao: ComplexTypeConfiguration<Endereco>
{
public EnderecoConfiguracao()
{
...
//fields
Property(e => e.Logradouro).HasColumnName("Logradouro").HasMaxLength(200);
}
}
public class EstadoConfiguracao: EntityTypeConfiguration<Estado>
{
public EstadoConfiguracao()
{
//Key
HasKey(e => e.Id);
//fields
Property(e => e.Nome).HasColumnName("Nome").HasMaxLength(50).IsRequired();
//table
ToTable("estado");
}
}
In my model, the Client has an Address, but when trying to map the State property of this address the following errors occurred:
1st Error: If I map Message State "Hba.HbaTools.Infraestrutura.EntityFramework.Estado: Name: Each type name in a schema must be unique. Type name 'Status' is already defined. "