Database ExtensionsNo TrackingT Method
This extension method is used to turn off query tracking in a data context when constructed.
Definition
Namespace: EWSoftware.EntityFramework
Assembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
The passed data context object
Assembly: EWSoftware.EntityFramework (in EWSoftware.EntityFramework.dll) Version: 2025.11.12.0
C#
public static T NoTracking<T>(
this T dataContext
)
where T : DbContext
VB
<ExtensionAttribute>
Public Shared Function NoTracking(Of T As DbContext) (
dataContext As T
) As TC++
public:
[ExtensionAttribute]
generic<typename T>
where T : DbContext
static T NoTracking(
T dataContext
)F#
[<ExtensionAttribute>]
static member NoTracking :
dataContext : 'T -> 'T when 'T : DbContextParameters
- dataContext T
- The data context in which to turn off query tracking.
Type Parameters
- T
- The data context type
Return Value
TThe passed data context object
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type T. 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).Remarks
This can improve performance if all you are doing is reading data without any updates. This
method can be used in conjunction with the OpenT(T) extension method as shown in the
example below.
Example
C#
using var dataContext = new MyDbContext().NoTracking();
... Execute commands ...
using var dataContext = new MyDbContext().NoTracking().Open();
... Execute commands ...