I am using EF Core to update thousands of records from a table called MyTable. It already has 1.500.000 rows. And here is the simple code I use to update one of its property called MyProp for each record with a different value for each of them:

```
using (MyDbContext ctx = new MyDbContext())
{
      var rows = ctx.Set<MyTable>().Take(1000000).ToList(); // I only take the first 1 million rows
      int idx = 0;
      foreach (var row in rows)
      {
           row.MyProp = $"MyNewValue{idx++}";
      }
      ctx.SaveChanges();
}

```

If I take one million rows to update them, while calling ctx.SaveChanges(), I get the following exception: ***Expected to read 4 header bytes but only received 0.*** (see below for the full stack trace)

I don't know why am I facing such exception, it appears if I take 1000000 rows but not if I take only 750000 for example.
I read it could be related to the timeout of the SQL server: which are listed below, but I really do not know if it is really related to one timeout and how I can find a solution. Should I divide the update into several ones and call several times SaveChanges()?

Thank you for any suggestions.

***Here are the timeouts from the MySql server:***

connect\_timeout 10

delayed\_insert\_timeout 300

have\_statement\_timeout YES

innodb\_flush\_log\_at\_timeout 1

innodb\_lock\_wait\_timeout 50

innodb\_print\_lock\_wait\_timeout\_info OFF

innodb\_rollback\_on\_timeout OFF

interactive\_timeout 610

lock\_wait\_timeout 31536000

net\_read\_timeout 30

net\_write\_timeout 60

rpl\_stop\_slave\_timeout 31536000

slave\_net\_timeout 60

thread\_pool\_idle\_timeout 60

wait\_timeout 610

***Here is the full stacktrace:***
From Microsoft.EntityFrameworkCore.Update : ERROR An exception occurred in the database while saving changes for context type 'MyDbContext'.
Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
---> MySql.Data.MySqlClient.MySqlException (0x80004005): Failed to read the result set.
---> System.IO.EndOfStreamException: Expected to read 4 header bytes but only received 0.
at MySqlConnector.Protocol.Serialization.ProtocolUtility.DoReadPayloadAsync(BufferedByteReader bufferedByteReader, IByteHandler byteHandler, Func`1 getNextSequenceNumber, ArraySegmentHolder`1 previousPayloads, ProtocolErrorBehavior protocolErrorBehavior, IOBehavior ioBehavior) in C:\projects\mysqlconnector\src\MySqlConnector\Protocol\Serialization\ProtocolUtility.cs:line 462
at MySqlConnector.Protocol.Serialization.StandardPayloadHandler.ReadPayloadAsync(ArraySegmentHolder`1 cache, ProtocolErrorBehavior protocolErrorBehavior, IOBehavior ioBehavior) in C:\projects\mysqlconnector\src\MySqlConnector\Protocol\Serialization\StandardPayloadHandler.cs:line 37
at MySqlConnector.Core.ServerSession.ReceiveReplyAsync(IOBehavior ioBehavior, CancellationToken cancellationToken) in C:\projects\mysqlconnector\src\MySqlConnector\Core\ServerSession.cs:line 665