title: Linq to sql add/update in different methods with different datacontexts
body: <p>I have to methods, Add() and Update() which both create a datacontext and returns the object created/updated. </p>
  
  <p>In my unit test I call first Add(), do some stuff and then call Update(). The problem is that Update() fails with the exception:</p>
  
  <pre><code>  System.Data.Linq.DuplicateKeyException: Cannot add an entity with a key that is already in use..
  </code></pre>
  
  <p>I understand the issue but want to know what to do about it? I've read a bit about how to handle multiple datacontext objects and from what I've heard this way is OK. </p>
  
  <p>I understand that the entity is still attached to the datacontext in Add() but I need to find out how to solve this?</p>
  
  <p>Thanks in advance</p>