Reputation: 786
I am getting the following error while trying to update an entity, 'An entity object cannot be referenced by multiple instances of IEntityChangeTracker' The code runs as,
dbUsers.Users.MergeOption = MergeOption.NoTracking;
dbUsers.Users.Attach(user);
dbUsers.ObjectStateManager.ChangeObjectState(user, System.Data.EntityState.Modified);
dbUsers.SaveChanges();
Please help me to get rid of it.
Upvotes: 0
Views: 2800
Reputation: 4293
If you use same Context*(dbUsers)* any where better to use context*(dbUsers)* as singleton instance.
This will Ensure a class has only one instance and provide a global point of access to it
Check this: http://www.dofactory.com/Patterns/PatternSingleton.aspx#_self1
Upvotes: 1