EntityCollection<TEntity>.Attach Method (IEnumerable<TEntity>)
Defines relationships between an object and a collection of related objects in an object context.
Assembly: System.Data.Entity (in System.Data.Entity.dll)
entities collection is null.
The relationship cannot be defined based on the EDM metadata. This can occur when the association in the conceptual schema does not support a relationship between the two types.
The Attach method is used to define relationships between an object and a collection of related objects when both the source object and the collection of related objects already exist in the object context. To attach an object or an object graph where the relationships are already defined, call the Attach method on the ObjectContext. To create a new object that is related to the source object, call the Add method on the EntityCollection<TEntity>. For more information, see Attaching Objects (Entity Framework).
If the collection is already filled or partially filled, the Attach method merges existing entities with the given entities. The given entities are not assumed to be the complete set of related entities.