I have 2 tables : Item and Location (one - many ).
I select one location and I try to update it
The entity goes from {Id=2, Name="name1",City="city1",Items=null}
to {Id=2, Name="name1", City="city2",Items=null}
and i want to save the updates.
The update method from the base class is:
public virtual void Update(T entity)
{
Entities.Attach(entity);
Context.ObjectStateManager
.ChangeObjectState(entity, System.Data.EntityState.Modified);
}
I make several updates just like this on other tables with no problems but in this case I get "An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key."
and I really don't understand why.