title: linq-to-sql "Cannot remove an entity that has not been attached"
body: <p>I'm getting the error <code>Cannot remove an entity that has not been attached.</code> when I try to delete a record. I've googled around and although there's plenty of places to find the solution to fix this problem, the suggested fix doesn't get me further:</p>
  
  <pre><code>using (MyDataContext TheDC = new MyDataContext())
  {
    TheDC.MyTable.Attach(ARecord); //added this line but doesn't fix it.
    TheDC.MyTable.DeleteOnSubmit(ARecord);
    TheDC.SubmitChanges();
  </code></pre>
  
  <p>My bigger question is this: does this issue ONLY affect delete queries or does it affect other kinds of queries too and I just haven't bumped into this problem yet. I've written an update query and it seems to work without running into this error.</p>
  
  <p>Thanks.</p>