title: Update and Add Child Rows at same time with Entity Framework
body: <p>i´m having some troubles when it comes to modify and add child rows at the same time. I´m using the technique from the answer: <a href="https://stackoverflow.com/questions/5557829/update-row-if-it-exists-else-insert-logic-with-entity-framework">stackoverflow.com/questions/5557829/...</a>.</p>
  
  <p>The problem is in the following code: </p>
  
  <pre><code>public void EditReport(tbl_inspection inspection)
  {
      foreach (var roll in inspection.tbl_inspection_roll)
      {                    
          container.tbl_inspection_roll.Attach(roll);
          container.ObjectStateManager.ChangeObjectState(roll, (roll.id_inspection_roll == 0) ? EntityState.Added : EntityState.Modified);
      }
  
      container.SaveChanges();
  }
  </code></pre>
  
  <p>I always have at least 1 row to update. When I have 1 row to add, it works fine, the problem is when I try to add more than 1 row at the same time, shows the well-known error: </p>
  
  <blockquote>
    <p>An object with the same key already exists in the ObjectStateManager.
    The ObjectStateManager cannot track multiple objects with the same
    key.</p>
  </blockquote>
  
  <p>Feels like I´m missing something here...</p>