DbContext.Attach DbContext.Attach DbContext.Attach Method

Definition

Overloads

Attach(Object) Attach(Object) Attach(Object)

Begins tracking the given entity in the Unchanged state such that no operation will be performed when SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. These entities will also begin to be tracked by the context. If a reachable entity has its primary key value set then it will be tracked in the Unchanged state. If the primary key value is not set then it will be tracked in the Added state. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

Attach<TEntity>(TEntity) Attach<TEntity>(TEntity) Attach<TEntity>(TEntity)

Begins tracking the given entity in the Unchanged state such that no operation will be performed when SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. These entities will also begin to be tracked by the context. If a reachable entity has its primary key value set then it will be tracked in the Unchanged state. If the primary key value is not set then it will be tracked in the Added state. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

Attach(Object) Attach(Object) Attach(Object)

Begins tracking the given entity in the Unchanged state such that no operation will be performed when SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. These entities will also begin to be tracked by the context. If a reachable entity has its primary key value set then it will be tracked in the Unchanged state. If the primary key value is not set then it will be tracked in the Added state. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

public virtual Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry Attach (object entity);
abstract member Attach : obj -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry
override this.Attach : obj -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry
Public Overridable Function Attach (entity As Object) As EntityEntry

Parameters

entity
Object Object Object

The entity to attach.

Returns

The EntityEntry for the entity. The entry provides access to change tracking information and operations for the entity.

Attach<TEntity>(TEntity) Attach<TEntity>(TEntity) Attach<TEntity>(TEntity)

Begins tracking the given entity in the Unchanged state such that no operation will be performed when SaveChanges() is called.

A recursive search of the navigation properties will be performed to find reachable entities that are not already being tracked by the context. These entities will also begin to be tracked by the context. If a reachable entity has its primary key value set then it will be tracked in the Unchanged state. If the primary key value is not set then it will be tracked in the Added state. An entity is considered to have its primary key value set if the primary key property is set to anything other than the CLR default for the property type.

public virtual Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<TEntity> Attach<TEntity> (TEntity entity) where TEntity : class;
abstract member Attach : 'Entity -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)> (requires 'Entity : null)
override this.Attach : 'Entity -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)> (requires 'Entity : null)
Public Overridable Function Attach(Of TEntity As Class) (entity As TEntity) As EntityEntry(Of TEntity)

Type Parameters

TEntity

The type of the entity.

Parameters

entity
TEntity TEntity TEntity

The entity to attach.

Returns

The EntityEntry<TEntity> for the entity. The entry provides access to change tracking information and operations for the entity.

Applies to