DbContext.SaveChanges DbContext.SaveChanges Method

Definition

Overloads

SaveChanges() SaveChanges()

Saves all changes made in this context to the database.

SaveChanges(Boolean) SaveChanges(Boolean)

Saves all changes made in this context to the database.

SaveChanges() SaveChanges()

Saves all changes made in this context to the database.

public virtual int SaveChanges()
Public Overridable Function SaveChanges As Integer

Returns

System.Int32 System.Int32

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.

SaveChanges(Boolean) SaveChanges(Boolean)

Saves all changes made in this context to the database.

public virtual int SaveChanges(bool acceptAllChangesOnSuccess)
Public Overridable Function SaveChanges(acceptAllChangesOnSuccess As Boolean) As Integer

Parameters

acceptAllChangesOnSuccess
System.Boolean System.Boolean

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

Returns

System.Int32 System.Int32

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.