title: DbContext.SaveChanges() causing DbUpdateException in loop
body: <p>I have a process that creates an object that is responsible for inserting into header /detail records. If I run the code to insert into the table on its own, every thing runs fine. However, when I call that code as a separate class within a loop I 
  get an exception:</p>
  
  <blockquote>
    <p>System.Data.Entity.Infrastructure.DbUpdateException was unhandled<br>
    Message=The INSERT statement conflicted with the FOREIGN KEY constraint "FK_CAS_ClaimsAdjustment_Header835". The conflict occurred in database "ERA835DB", table "dbo.Header835", column 'TRANSACTIONID'.</p>
  </blockquote>
  
  <p>The <code>TRANSACTIONID</code> Column in the <code>Header</code> table is set as <code>Identity=True</code>. The child table, <code>CAS_ClaimsAdjustment</code> has a column <code>TransactionID</code> that is FK to <code>Header.TransactionID</code>.</p>
  
  <p>Why does <code>DBContext.SaveChanges()</code> seem to behave differently depending on how the same code is called?</p>
  
  <pre><code> foreach (var file in Files)
    { 
            Parser parser = new Parser();
            parser.HandleFile(file);
    }
  
  
  public class Parser
  {
  
    public void HandleFile(string file)
    {
        using (Model.DbContext dbcontext)
      {
          foreach (var itemn in file)
          {
             Claims claim = new Claims();
  
              // ...
  
             dbcontext.Claims.Add(claim);
          }
  
          dbcontext.SaveChanges();
  
      }
    }
  
  
  }
  </code></pre>