DbContext.SaveChanges Method ()

Entity Framework 6.0

Saves all changes made in this context to the underlying database.

Namespace:   System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

public virtual int SaveChanges()

Return Value

Type: System.Int32

The number of objects written to the underlying database.

Exception Condition

An error occurred sending updates to the database.


A database command did not affect the expected number of rows. This usually indicates an optimistic concurrency violation; that is, a row has been changed in the database since it was queried.


The save was aborted because validation of entity property values failed.


An attempt was made to use unsupported behavior such as executing multiple asynchronous commands concurrently on the same context instance.


The context or connection have been disposed.


Some error occurred attempting to process entities in the context either before or after sending commands to the database.

Return to top