title: System.Data.Linq.DuplicateKeyException: Cannot add an entity with a key that is already in use
body: <p>mine is windows application. I am trying to insert a record through a LINQ DataContext. It has Unique identifier in the table. Even i am executing a trigger after insertion. So i am making a select query in the end of the trigger to get the auto generator number and to avoid auto-sync error. As it's a windows application i can keep the Context for longtime. When i create a new object ( for example order) and do the same previous operation, upon SubmitChanges operation, it shows cannot have duplicate key. Can't i use this same Context to Insert the second record? Or do i need to create a new Context to insert a new Record?(Does this Unit of work Concept comes here?). Creating new Context is bad idea as i need to load all data again.. </p>
  
  <p>Any thought?</p>
  
  <p>Let me put some code sample to voice my situation.</p>
  
  <pre><code>CallCenterLogObjCotext = (CallCenterLogObjCotext == null ? (new CallcenterLogContext) : (CallCenterLogObjCotext));
  
  CallDetail newCallDetailsOpenTicket = new CallDetail();
  
  newCallDetailsOpenTicket.CallPurpose = (from callpuposelist in CallCenterLogObjCotext.CallPurposes where callpuposelist.CallPurposeID == ((CallPurpose)(cbcallpurpose.SelectedItem)).CallPurposeID select callpuposelist).FirstOrDefault();
  </code></pre>
  
  <p>Lots of settings like this ...</p>
  
  <pre><code>CallCenterLogObjCotext.CallDetails.InsertOnSubmit(newCallDetailsOpenTicket); CallCenterLogObjCotext.SubmitChanges();
  </code></pre>
  
  <p>As i mentioned above, this is a click on Open Ticket button on windows form. I change the values of fname, lname and all in the textboxes available on that form and clicked the same button. So it will call the same method again. I get the below specified error. System.Data.Linq.DuplicateKeyException: Cannot add an entity with a key that is already in use.</p>
  
  <p>Thanks.</p>