I was wondering why the AutoDetectChangesEnabled
property on the DbContext is set to false by default.
I want to bulk insert into my context and as you might know turning the auto-detection to false brings way better performances.
I mean, if i know when to detect the changes to my context, is there any reason why i shouldn't set AutoDetectChangesEnabled
to false
?
I think it is likely they wanted the more common and very useful behavior to work out of the box.
var mycontext = new DemoContext();
var myEntity = myContent.Thinhymybobs.find(akey);
myEntity.PropX = newvalue;
mycontext.saveChnages();
The update sent to the the DB is delta aware and the update set statement is used accordingly. So this is friendly on the DB.
When doing "bulk" operations on a DB, performance questions are normally a natural thought. So wondering about turning change off or indeed EVEN using tracking is a likely question i feel.
This article may interest you. State of an entry. http://msdn.microsoft.com/en-us/data/jj592676.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With