title: EF Code First: is good to call DetectChanges just before SaveChanges?
body: <p>I have read few articles (<a href="https://stackoverflow.com/questions/5943394/why-is-inserting-entities-in-ef-4-1-so-slow-compared-to-objectcontext">article1</a>, <a href="http://patrickdesjardins.com/blog/entity-framework-increasing-performance-with-autodetectchangesenabled" rel="noreferrer">article2</a>) about Entity Framework that it calls DetectChanges many times, which makes it very slow when working with large amounts of data.</p>
  
  <p>Can i, for example, disable the <code>autoDetectChanges</code> when i initialize the context, and just call <code>DetectChanges()</code> before calling <code>.SaveChanges()</code>?</p>
  
  <p>Will the context recognize the inserted/changed/deleted entities?</p>
  
  <pre><code>var _dbContext = new ProjectContext();
  _dbContext.Configuration.AutoDetectChangesEnabled = false;
  
  // add/edit/delete entities
  
  _dbContext.ChangeTracker.DetectChanges();
  _dbContext.SaveChanges();
  </code></pre>
  
  <p>Should this approach work? or it may create hidden bugs?</p>