Share via


ObjectContext.AttachTo(String, Object) Method

Definition

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

public virtual void AttachTo (string entitySetName, object entity);
abstract member AttachTo : string * obj -> unit
override this.AttachTo : string * obj -> unit
Public Overridable Sub AttachTo (entitySetName As String, entity As Object)

Parameters

entitySetName
String

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

entity
Object

The Object to attach.

Exceptions

The entity is null.

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.

Applies to