This article provides some evidence that turning off AutoDetectChanges on your Entity Framework data context can provide a significant performance improvement when inserting large numbers of entities.
context.Configuration.AutoDetectChangesEnabled = false;
However, the DataContext provided by the SqlEntityConnection type provider doesn't seem to provide any way to control this setting.
There's no context.Configuration
property, or context.DataContext.Configuration
property. There is a context.DataContext.ContextOptions
but it has nothing even resembling AutoDetectChangesEnabled
.
The DataContext
property on the type provider context is of type System.Data.Objects.ObjectContext
. Does anyone know of a way to influence this particular setting from there?
I wrote a pretty similar article last year on detect changes performance which you can find here: http://blog.staticvoid.co.nz/2012/5/7/entityframework_performance_and_autodetectchanges My experience is mostly with DbContext (which wraps ObjectContext) but i did a bit of a search and found the following
Why is inserting entities in EF 4.1 so slow compared to ObjectContext?
what this says is that ObjectContext doesnt actually do automatic change detection so this isnt something you should need to worry about. However you still do need to be aware that large object graphs will slow things down as is all snapshot tracking scenarios detect changes is required at some point, and this involves full enumeration of the object graph