DbContext.SaveChanges DbContext.SaveChanges DbContext.SaveChanges Method

Definition

Overloads

SaveChanges(Boolean) SaveChanges(Boolean) SaveChanges(Boolean)

Saves all changes made in this context to the database.

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.

SaveChanges() SaveChanges() SaveChanges()

Saves all changes made in this context to the database.

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.

SaveChanges(Boolean) SaveChanges(Boolean) SaveChanges(Boolean)

Saves all changes made in this context to the database.

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.

[System.Diagnostics.DebuggerStepThrough]
public virtual int SaveChanges (bool acceptAllChangesOnSuccess);
abstract member SaveChanges : bool -> int
override this.SaveChanges : bool -> int
Public Overridable Function SaveChanges (acceptAllChangesOnSuccess As Boolean) As Integer

Parameters

acceptAllChangesOnSuccess
Boolean Boolean Boolean

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

Returns

The number of state entries written to the database.

Exceptions

An error is encountered while saving to the database.

A concurrency violation is encountered while saving to the database. A concurrency violation occurs when an unexpected number of rows are affected during save. This is usually because the data in the database has been modified since it was loaded into memory.

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.

SaveChanges() SaveChanges() SaveChanges()

Saves all changes made in this context to the database.

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.

[System.Diagnostics.DebuggerStepThrough]
public virtual int SaveChanges ();
abstract member SaveChanges : unit -> int
override this.SaveChanges : unit -> int
Public Overridable Function SaveChanges () As Integer

Returns

The number of state entries written to the database.

Exceptions

An error is encountered while saving to the database.

A concurrency violation is encountered while saving to the database. A concurrency violation occurs when an unexpected number of rows are affected during save. This is usually because the data in the database has been modified since it was loaded into memory.

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.

Applies to