title: For Each Loop LINQ Insert giving me Cannot add an entity that already exists
body: <p>I have the following code, that in my head should create a new row in a table:</p>
  
  <pre><code>Dim fin As Boolean
  Dim db2 As New ChecklistModeldbmlDataContext
  For Each a In bServers
  
     If collection("fin" &amp; a.ServerName) = "true, false" Or collection("fin" &amp; a.ServerName) = "true,false" Then
         fin = True
     Else
         fin = False
     End If
  
     bLog.AMLogID = amLog.LogID
     bLog.ByteCount = collection("bytes" &amp; a.ServerName)
     bLog.DurationHours = collection("hours" &amp; a.ServerName)
     bLog.DurationMinutes = collection("minutes" &amp; a.ServerName)
     bLog.DurationSeconds = collection("seconds" &amp; a.ServerName)
     bLog.IsFinished = fin
     bLog.ServerID = a.ServerID
     bLog.DetailsAndErrors = collection("details" &amp; a.ServerName)
  
     db2.BackupLogs.InsertOnSubmit(bLog)
     db2.SubmitChanges()
  Next
  </code></pre>
  
  <p>It only ever adds one record in to the table and then errors with Cannot add an entity that already exists.</p>
  
  <p>Now it should enter 4 rows into the table, but I can't work out why the above gives me that error.</p>
  
  <p>I've also tried having the db2.SubmitChanges() outside of the for each and it just inserts the last row.</p>
  
  <p>Any thoughts?</p>