ObjectContext.AttachTo Method (String, Object)

 

Attaches an object or object graph to the object context in a specific entity set.

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

public virtual void AttachTo(
	string entitySetName,
	object entity
)

Parameters

entitySetName
Type: System.String

Represents the entity set name, which may optionally be qualified by the entity container name.

entity
Type: System.Object

The Object to attach.

Exception Condition
ArgumentNullException

The entity is null.

InvalidOperationException

Invalid entity set or the object has a temporary key or the object has an EntityKey and the EntitySet does not match with the entity set passed in as an argument of the method or the object does not have an EntityKey and no entity set is provided or any object from the object graph has a temporary EntityKey or any object from the object graph has an invalid EntityKey (for example, values in the key do not match values in the object) or the entity set could not be found from a given entitySetName name and entity container name or any object from the object graph already exists in another state manager.