objectstatemanager

Unable to attach a detached entity: "An object with the same key already exists in the ObjectStateManager".

Hi I am trying to attach an entity to the ObjectContext. When I do so, the following InvalidOperationException is thrown: An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key. I checked in the object state manager and the item does not exist: //D...

When querying with 'Include', does the EF checks if objects already exist in object state manager?

Should I avoid using Include in queries, or I can rely on the EDM that when it creates the query it excludes from the query items that already exist in the OSM? ...

ObjectContext.Refresh() ???

How to update ALL the dirty entities from the data store, and reset their changed values to the original store value? The method ObjectContext.Refresh requires as a parameter the entities to be refreshed. ...

enforcing ObjectStateManager entry deletion on page leave

I have a edited RESTful wizard based upon Shoulders of Giants | A RESTful Wizard Using ASP.Net MVC… Perhaps? . This wizard has a CANCEL button which, when pressed, fires the code below. // If the user cancels, drop out altogether if (!string.IsNullOrEmpty(CANCEL_BUTTON)) { Session.Remove(VACANCYWIZARD_SESSION_KEY); repository...

Problem with UPDATE Operation On Entity Framework 4 (Pure POCOs)

Hi Guys, I have an Entity Framework 4.0 model implemented with pure POCO's (no code generation, no self-tracking entities, just plain old CLR objects). Now, here is some code i have in my UI to perform an UPDATE: [HttpPost] public ActionResult UpdatePerson(Person person) { repository.Attach(person); unitOfWork.Commit(); } Es...