ardalis/EFCore.Extensions

Add Extensions to Enable/Disable tracking on a DbContext

Offen

#1 geöffnet am 06.08.2019

 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C# (8 Forks)github user discovery
good first issue

Repository-Metriken

Stars
 (44 Sterne)
PR-Merge-Metriken
 (Keine gemergten PRs in 30 T)

Beschreibung

If you want to force the dbContext to make a new db call instead of relying on its identity map, you can do so with this approach:

dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
var fromDb = await dbContext. [whatever query]
dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.TrackAll;

Create extension methods that simply turn off tracking and then turn it back on that require less code than assigning to the QueryTrackingBehavior does.

Contributor Guide