DbContext.SaveChangesAsync DbContext.SaveChangesAsync Method

Definition

Overloads

SaveChangesAsync(CancellationToken) SaveChangesAsync(CancellationToken)

Asynchronously saves all changes made in this context to the database.

SaveChangesAsync(Boolean, CancellationToken) SaveChangesAsync(Boolean, CancellationToken)

Asynchronously saves all changes made in this context to the database.

SaveChangesAsync(CancellationToken) SaveChangesAsync(CancellationToken)

Asynchronously saves all changes made in this context to the database.

public virtual Task<int> SaveChangesAsync(CancellationToken cancellationToken = null)
Public Overridable Function SaveChangesAsync(cancellationToken As CancellationToken = Nothing) As Task(Of Integer)

Parameters

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns

System.Threading.Tasks.Task<System.Int32> System.Threading.Tasks.Task(Of System.Int32)

A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database.

Remarks

This method will automatically call DetectChanges() to discover any changes to entity instances before saving to the underlying database. This can be disabled via AutoDetectChangesEnabled.

Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.

SaveChangesAsync(Boolean, CancellationToken) SaveChangesAsync(Boolean, CancellationToken)

Asynchronously saves all changes made in this context to the database.

public virtual Task<int> SaveChangesAsync(bool acceptAllChangesOnSuccess, CancellationToken cancellationToken = null)
Public Overridable Function SaveChangesAsync(acceptAllChangesOnSuccess As Boolean, cancellationToken As CancellationToken = Nothing) As Task(Of Integer)

Parameters

acceptAllChangesOnSuccess
System.Boolean System.Boolean

Indicates whether AcceptAllChanges() is called after the changes have been sent successfully to the database.

cancellationToken
System.Threading.CancellationToken System.Threading.CancellationToken

A System.Threading.CancellationToken to observe while waiting for the task to complete.

Returns

System.Threading.Tasks.Task<System.Int32> System.Threading.Tasks.Task(Of System.Int32)

A task that represents the asynchronous save operation. The task result contains the number of state entries written to the database.

Remarks

This method will automatically call DetectChanges() to discover any changes to entity instances before saving to the underlying database. This can be disabled via AutoDetectChangesEnabled.

Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.