title: EF Core - Invalid attempt to call CheckDataIsReady when reader is closed (OutOfMemory)
body: <p>I have a table <strong>dbo.Cache</strong> in SQL server, with two Columns:</p>
  
  <ul>
  <li>Key : varchar(50)</li>
  <li>Value : nvarchar(max)</li>
  </ul>
  
  <p>I am planning to store large strings in Value column (>30mb) and query them in multiple threads.</p>
  
  <p>So the problem that when I do more then 9 queries in parallel, it starts throwing exception <code>System.InvalidOperationException : Invalid attempt to call CheckDataIsReady when reader is closed</code>:</p>
  
  <pre><code>[Fact]
  public void TestMemory()
  {
      const string key = "myKey1";
      //re-creating record with Value = large 30mb string
      using (var db = new MyDbContext())
      {
          var existingRecord = db.CachedValues.FirstOrDefault(e =&gt; e.Key == key);
          if (existingRecord!=null)
          {
              db.Remove(existingRecord);
              db.SaveChanges();
          }
  
          var myHugeString = new string('*',30*1024*1024);
          db.CachedValues.Add(new CachedValue() {Key = key, Value = myHugeString});
          db.SaveChanges();
      }
  
      //Try to load this record in parallel threads, creating new dbContext
      const int threads = 10;
      Parallel.For(1, threads, new ParallelOptions(){MaxDegreeOfParallelism = threads}, (i) =&gt;
      {
          using (var db = new MyDbContext())
          {
              var entity = db.CachedValues.FirstOrDefault(c =&gt; c.Key == key);
          }
      });
  }
  </code></pre>
  
  <p>Tried to execute <code>GC.Collect(); GC.WaitForFullGCComplete();</code> before/after each db read - didn't not help</p>
  
  <p>Tried to mimic this behavior on the lower level directly reading data through <code>sqlDataReader.ExecuteReader(CommandBehavior.SequentialAccess)</code> - it throws <code>OutOfMemoryException</code></p>