DatabaseExtensionsHasChanges Method

This extension method is used to see if a data context has any unsaved changes.

Definition

Namespace: EWSoftware.EntityFramework
Assembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
public static bool HasChanges(
	this DbContext dataContext
)

Parameters

dataContext  DbContext
The data context to check

Return Value

Boolean
True if the data context's change set has any inserted, updated, or deleted items waiting to be submitted, false if not.

Usage Note

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).

Example

C#
if(dataContext.HasChanges())
    dataContext.SaveChanges();

See Also