Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[This page is specific to the Entity Framework version 6. The latest version is available as the 'Entity Framework' NuGet package. For more information about Entity Framework, see msdn.com/data/ef.]
Saves all changes made in this context to the underlying database.
Namespace: System.Data.Entity
Assembly: EntityFramework (in EntityFramework.dll)
'Declaration
Public Overridable Function SaveChanges As Integer
'Usage
Dim instance As DbContext
Dim returnValue As Integer
returnValue = instance.SaveChanges()
public virtual int SaveChanges()
public:
virtual int SaveChanges()
abstract SaveChanges : unit -> int
override SaveChanges : unit -> int
public function SaveChanges() : int
Type: System.Int32
The number of objects written to the underlying database.
Exception | Condition |
---|---|
DbUpdateException | An error occurred sending updates to the database. |
DbUpdateConcurrencyException | 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. |
DbEntityValidationException | The save was aborted because validation of entity property values failed. |
NotSupportedException | An attempt was made to use unsupported behavior such as executing multiple asynchronous commands concurrently on the same context instance. |
ObjectDisposedException | The context or connection have been disposed. |
InvalidOperationException | Some error occurred attempting to process entities in the context either before or after sending commands to the database. |