Disable AutoDetectChanges on Entity Framework Core

asp.net-core c# entity-framework-core record sql

Question

someone knows how to disable the AutoDetectChanges on EFCore?

I need to do it because I have to make an huge import in my database, and can't find information on web.

Tried this but it's not working:

_context.Configuration.AutoDetectChangesEnabled = false;

Say configuration does not exist.

Thanks a lot.

1
1
1/9/2020 4:24:40 PM

Popular Answer

What you have tried

_context.Configuration.AutoDetectChangesEnabled = false;

is for EF6.

The corresponding EF Core option AutoDetectChangesEnabled is property of the ChangeTracker associated with the DbContext, so the corresponding code is

_context.ChangeTracker.AutoDetectChangesEnabled = false;
2
1/9/2020 6:45:50 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow