EntityReference<TEntity>.Attach Method (TEntity)

 

Creates a many-to-one or one-to-one relationship between two objects in the object context.

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

public void Attach(
	TEntity entity
)

Parameters

entity
Type: TEntity

The object being attached.

Exception Condition
ArgumentNullException

When the entity is null.

InvalidOperationException

When the entity cannot be related to the current related end. This can occur when the association in the conceptual schema does not support a relationship between the two types.