Pregunta

public class Attribute
{
    [Key]
    public int AttributeId { get; set; }

    [Required, StringLength(100)]
    public string Name { get; set; }

    public int ValueAttributeId { get; set; }
    public Attribute ValueAttribute { get; set; }

    public IList<Attribute> ValueAttributes { get; set; }
}

  modelBuilder.Entity<Attribute>()
     .HasOptional(a => a.ValueAttribute)
     .WithMany(a => a.ValueAttributes)
     .HasForeignKey(a => a.ValueAttributeId);

tsystem.data.entity.Edm.EdMassociationType :: En conflictos de multiplicidad con la restricción referencial en el rol 'Attribute_valueAttribute_Target' en la relación 'atribute_valueeattribute'. Debido a que todas las propiedades en el papel dependiente no son anulables, la multiplicidad del papel principal debe ser '1'.

Aaaaahhhh .....

¿Fue útil?

Solución

public int ? ValueAttributeId { get; set; }

... La propiedad debía ser nula.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top