DbContext.Update DbContext.Update DbContext.Update Method

Definition

Overloads

Update(Object) Update(Object) Update(Object)

Begins tracking the given entity in the Modified state such that it will be updated in the database when SaveChanges() is called.

All properties of the entity will be marked as modified. To mark only some properties as modified, use Attach(Object) to begin tracking the entity in the Unchanged state and then use the returned EntityEntry to mark the desired properties as modified.

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 Modified 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.

Update<TEntity>(TEntity) Update<TEntity>(TEntity) Update<TEntity>(TEntity)

Begins tracking the given entity in the Modified state such that it will be updated in the database when SaveChanges() is called.

All properties of the entity will be marked as modified. To mark only some properties as modified, use Attach<TEntity>(TEntity) to begin tracking the entity in the Unchanged state and then use the returned EntityEntry to mark the desired properties as modified.

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 Modified 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.

Update(Object) Update(Object) Update(Object)

Begins tracking the given entity in the Modified state such that it will be updated in the database when SaveChanges() is called.

All properties of the entity will be marked as modified. To mark only some properties as modified, use Attach(Object) to begin tracking the entity in the Unchanged state and then use the returned EntityEntry to mark the desired properties as modified.

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 Modified 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 Update (object entity);
abstract member Update : obj -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry
override this.Update : obj -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry
Public Overridable Function Update (entity As Object) As EntityEntry

Parameters

entity
Object Object Object

The entity to update.

Returns

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

Update<TEntity>(TEntity) Update<TEntity>(TEntity) Update<TEntity>(TEntity)

Begins tracking the given entity in the Modified state such that it will be updated in the database when SaveChanges() is called.

All properties of the entity will be marked as modified. To mark only some properties as modified, use Attach<TEntity>(TEntity) to begin tracking the entity in the Unchanged state and then use the returned EntityEntry to mark the desired properties as modified.

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 Modified 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> Update<TEntity> (TEntity entity) where TEntity : class;
abstract member Update : 'Entity -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)> (requires 'Entity : null)
override this.Update : 'Entity -> Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<'Entity (requires 'Entity : null)> (requires 'Entity : null)
Public Overridable Function Update(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 update.

Returns

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

Applies to