DatabaseExtensionsHasChanges Method
This extension method is used to see if a data context has any unsaved changes.
Namespace: EWSoftware.EntityFrameworkAssembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
public static bool HasChanges(
this DbContext dataContext
)
<ExtensionAttribute>
Public Shared Function HasChanges (
dataContext As DbContext
) As Boolean
public:
[ExtensionAttribute]
static bool HasChanges(
DbContext^ dataContext
)
[<ExtensionAttribute>]
static member HasChanges :
dataContext : DbContext -> bool
- dataContext DbContext
- The data context to check
BooleanTrue if the data context's change set has any inserted, updated, or deleted items waiting to
be submitted, false if not.In Visual Basic and C#, you can call this method as an instance method on any object of type
DbContext. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
if(dataContext.HasChanges())
dataContext.SaveChanges();