Is there a way to control AutoDetectChanges on a SqlEntityConnection?

This article provides some evidence that disabling AutoDetectChanges in the context of Entity Framework data can provide significant performance improvements when inserting a large number of objects.

context.Configuration.AutoDetectChangesEnabled = false; 

However, the DataContext provided by the provider of type SqlEntityConnection does not seem to provide the ability to control this parameter.

There is no context.Configuration property or context.DataContext.Configuration property. There is context.DataContext.ContextOptions , but it has nothing to do with AutoDetectChangesEnabled .

The DataContext property in the context of the type provider is of type System.Data.Objects.ObjectContext . Does anyone know how to affect this particular parameter?

+4
source share
1 answer

Last year, I wrote a pretty similar article about detecting performance changes, which you can find here: http://blog.staticvoid.co.nz/2012/5/7/entityframework_performance_and_autodetectchanges My experience is mainly related to DbContext (which wraps ObjectContext) but I searched a bit and found the following

Why is adding objects in EF 4.1 so slow compared to ObjectContext?

that this suggests that the ObjectContext does not actually automatically detect changes, so that’s not what you need to worry about. However, you still need to know that large object graphs are slowing down because all snapshot tracking scripts detect changes at some point, and this includes a complete listing of the object graph

+5
source

All Articles