title: Update the same field on many records
body: <p>With EF Core: Is there a way to tell it that the new value in the single field I update is the same for all entities and make it update the entities with one/few SQL statements?</p>
  
  <p>I want to set a timestamp on a lot of records at the same time.
  I currently have this code:</p>
  
  <pre><code>var downloadTimeStamp = DateTime.UtcNow;
  
  foreach (var e in entities)
  {
      e.DownloadDateTime = downloadTimeStamp;
  }
  await db.SaveChangesAsync();
  </code></pre>
  
  <p>It generates SQL that executes one UPDATE statement for each entity. E.g.:</p>
  
  <pre><code>UPDATE [TableName] SET [DownloadDateTime] = @p1988
    WHERE [Id] = @p1989;
    SELECT @@ROWCOUNT;
  </code></pre>
  
  <p>Is that really the most optimal way to do this? Is it possible to make EF Core do this in fewer SQL statements?</p>
  
  <p>In my current dataset there are 100,000 records that need to be updated. It is not the full contents of the table, only a subset. It takes about 90 seconds to do the above updates when running the code inside Visual Studio with a SQL server express on my local PC. When running in a small Azure web app with a small SQL server Azure instance, it takes several minutes. That's why I'm looking to optimize it, if possible.</p>