3
I’m having a hard time with a mapping and I’d like to know if it’s possible to do that:
I have a Contact class with two fields that are Valueobject type "Phone", the fields are Phone and Mobile.
public Telefone Telefone { get; set; }
public Telefone Celular { get; set; }
I would like to do the following mapping, so that Phone is mandatory and mobile is not:
Property(x => x.Telefone.DDD)
.HasColumnName("TelefoneDDD")
.IsRequired();
Property(x => x.Telefone.Numero)
.HasColumnName("Telefone")
.IsRequired();
Property(x => x.Celular.DDD)
.HasColumnName("CelularDDD")
.IsOptional();
Property(x => x.Celular.Numero)
.HasColumnName("Celular")
.IsOptional();
When I have Migration generated, it returns the following error:
Conflicting Configuration Settings Were specified for Property 'Numero' on type 'Sistemateste.domain.Valueobject.Phone': Isnullable = False Conflicts with Isnullable = True
Note: If I put all as Isoptional or Isrequired they work.
– Iran Oliveira
You could put in your question the definition of the complex object
Telefone
?– Leonel Sanches da Silva