Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ObjectContext::AttachTo Method (String^, Object^)

Entity Framework 6.0
 

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.

Return to top
Show: