I'm working with Entity Framework 4.5.2, Visual Studio 2015
I have the following entity.
public class Especificacion
{
public int EspecificacionId { get; set; }
public string Nombre { get; set; }
public virtual ICollection<Opcion> Opciones { get; set; }
}
At the moment of updating I only want to update the header but not the Options list, it occurs to me that I must separate from the Options context.
public void Actualizar(Especificacion entity)
{
using (var context = new BusinessContext())
{
foreach (var d in entity.Opciones)
{
context.Entry(d).State = EntityState.Detached;
}
context.Entry(entity).State = EntityState.Modified;
context.SaveChanges();
}
}
But in entity equal comes options, how can I solve it?
Error: {"Conflicting changes to the role have been detected 'Option_Specification_Target' of the relationship 'TecSoftware.Persistencia.Model.Opcion_Specificacion'. "}
For some reason there are problems in the model
Greetings!
Specifications
- SpecificationId int
- Name varchar (80)
Options
- Option int
- SpecificationId int
- Name vaarchar (80)