ObjectContext.Detach Method (Object)

 

Removes the object from the object context.

Namespace:   System.Data.Entity.Core.Objects
Assembly:  EntityFramework (in EntityFramework.dll)

public virtual void Detach(
	object entity
)

Parameters

entity
Type: System.Object

Object to be detached. Only the entity is removed; if there are any related objects that are being tracked by the same ObjectStateManager , those will not be detached automatically.

Exception Condition
ArgumentNullException

The entity is null.

InvalidOperationException

The entity is not associated with this ObjectContext (for example, was newly created and not associated with any context yet, or was obtained through some other context, or was already detached).