title: Entity Framework 4 Out of Memory on SaveChanges
body: <p>I have a table that contains greater than half a million records.  Each record contains about 60 fields but we only make changes to three of them.</p>
  
  <p>We make a small modification to each entity based on a calculation and a look up.</p>
  
  <p>Clearly I can't update each entity in turn and then <code>SaveChanges</code> as that would take far too long.</p>
  
  <p>So at the end of the whole process I call <code>SaveChanges</code> on the <code>Context</code>.</p>
  
  <p>This is causing an Out of Memory error when i apply <code>SaveChanges</code></p>
  
  <p>I'm using the DataRepository pattern.</p>
  
  <pre><code>//Update code
  DataRepository&lt;ExportOrderSKUData&gt; repoExportOrders = new DataRepository&lt;ExportOrderSKUData&gt;();
  foreach (ExportOrderSKUData grpDCItem in repoExportOrders.all())
  {
    ..make changes to enity..
  }
  repoExportOrders.SaveChanges();
  
  
  
  //Data repository snip
  public DataRepository()
  {
    _context = new tomEntities();
    _objectSet = _context.CreateObjectSet&lt;T&gt;();
  }
  public List&lt;T&gt; All()
  {
    return _objectSet.ToList&lt;T&gt;();
  }
  public void SaveChanges()
  {
    _context.SaveChanges();
  }
  </code></pre>
  
  <p>What should I be looking for in this instance?</p>