I have the following method:
public void SaveChanges(List<nHydrate.EFCore.DataAccess.IBusinessObject> entities)
using (var cont = new MyEntities(ConnectionString))
foreach (nHydrate.EFCore.DataAccess.IBusinessObject entity in entities)
var state = ((System.Data.Objects.DataClasses.EntityObject)entity).EntityState;
I pass to the method a List of entities, each of which has its EntityState = Modified.
I know that when I attach an entity, its state is reset to unchanged, and this is why I keep its original state in the state variable before attaching and set it back after attachment with the ChangeObjectState method.
Unfortunately, after attaching the first entity in the list, ALL the remaining entities in the list have their EntityState reset to Unchanged!! And this is why the SaveChanges has effect only for the first entity of the list.
Am I missing something? Is this a known behaviour?
All the best,