EntityCollection<TEntity>.Attach Method
Attaches an entity to the EntityCollection.
Assembly: EntityFramework (in EntityFramework.dll)
Name | Description | |
---|---|---|
![]() | Attach(TEntity) | Defines a relationship between two attached objects in an object context. |
![]() | Attach(IEnumerable<TEntity>) | Defines relationships between an object and a collection of related objects in an object context. |
EntityCollection<TEntity>.Attach Method (TEntity)
Defines a relationship between two attached objects in an object context.
Exception | Condition |
---|---|
ArgumentNullException | When the entity is null. |
InvalidOperationException |
EntityCollection<TEntity>.Attach Method (IEnumerable<TEntity>)
Defines relationships between an object and a collection of related objects in an object context.
Exception | Condition |
---|---|
ArgumentNullException | entities collection is null. |
InvalidOperationException |
Loads related entities into the local collection. If the collection is already filled or partially filled, merges existing entities with the given entities. The given entities are not assumed to be the complete set of related entities. Owner and all entities passed in must be in Unchanged or Modified state. We allow deleted elements only when the state manager is already tracking the relationship instance.