Attaching and detaching objects to and from ObjectContext
You can use the
Attach or Detach methods of the ObjectContext class to attach or detach objects. It should be noted that Attach will attach the entire object graph. The method cannot determine which objects are new and which already exist in ObjectContext. Note that when you execute a query on ObjectContext, the objects that are returned as a result of the query are attached in ObjectContext.
You can attach an object to ObjectContext by calling any of the following methods on ObjectContext:
AttachAddObjectAttachToApplyPropertyChanges
But what does Attach and Detach mean here? You use Attach to attach an object to the context. You should use Attach when the entity already exists in the database and you want the context to know about it without performing a query to locate the entity. When you attach an entity to ObjectContext using the Attach method, it sets EntityState of the object being attached to the Unchanged state. In...