Search code examples
c#sqlasp.net-coreentity-framework-corerecord

Disable AutoDetectChanges on Entity Framework Core


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.


Solution

  • 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;