title: EF SaveChangesAsync extremely slow
body: <p>I have a table in which I want to update 100 rows at a time. I have a list of the 100 IDs that I use to find the specific rows. Once found, I update a single column (SyncOk) for each row.</p>
  
  <p>The problem is that updating 100 rows takes around <strong>23 to 30 seconds</strong>.</p>
  
  <pre><code>dbContext.Configuration.ValidateOnSaveEnabled = false;
  var count = ids.Count;
  for (var i = 0; i &lt; count; i++)
  {
      var id = ids[i];
      var record = await dbContext.History
          .FirstOrDefaultAsync(r =&gt; r.Id == id);
      record.SyncOk = syncOk;
  }
  await dbContext.SaveChangesAsync();
  </code></pre>
  
  <p>Some notes:</p>
  
  <ul>
  <li><code>ids</code> is an <code>IList&lt;long&gt;</code> that holds all IDs of interest.</li>
  <li><code>syncOk</code> is a bool.</li>
  <li>I've tried to set the <code>AutoDetectChangesEnabled</code> property to false, and then updating the record manually just after setting the <code>SyncOk</code> value - doesn't speed things up.</li>
  </ul>
  
  <p>Why is <code>SaveChangesAsync()</code> so slow - <em>how can I increase the speed of the above functionality?</em> I'm afraid that the table is locked during the 23-30 seconds and will make other services (that use the same table) unable to update it as well.</p>