title: How to avoid System.Data.Entity.Infrastructure.DbUpdateException
body: <p>I have this DbContext object which consists of -</p>
  
  <pre><code>- Employee
  - CompanyAddress  (PK: AddressFirstLine, City)
  Note: one Employee can have many CompanyAddress
  </code></pre>
  
  <p>Records are added to CompanyAddress table <em>only if</em> some address doesn't exists in CompanyAddress table.<br>
  If I have two DBContext objects from database say Snapshot1, Snapshot2.
  Say when both these snapshots were taken, there were no records in CompanyAddress table.
  When changes were made to Snapshot1 and saved - records are written to CompanyAddress table.<br>
  When changes were made to Snapshot2 and saved using</p>
  
  <pre><code>mydataContext.SaveChanges();
  </code></pre>
  
  <p>exception occurs:</p>
  
  <pre><code>System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries
  System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK_CompanyAddress'. Cannot insert duplicate key in object 'dbo.CompanyAddress'
  </code></pre>
  
  <p>It seems saving of Snapshot1 made Snapshot2 dirty because when they are saved back to database, both had <em>same</em> CompanyAddress records.</p>
  
  <p>What other call/settings I can make on dbContext object to avoid this error?</p>
  
  <p>Thank you!</p>