title: An entity object cannot be referenced by multiple instances of IEntityChangeTracker
body: <p>I use EF as ORM.</p>
  
  <p>I dispose the <code>objectContext</code> on every request.</p>
  
  <p>I save the entities in a cache layer, as my service gets lots of traffic.</p>
  
  <p>I got sometimes get the error <code>objectContext already disposed</code> for some entities that I got from the cache.</p>
  
  <p>I have added this code to elements that were retrived from the cache</p>
  
  <pre class="lang-csharp prettyprint-override"><code>if (maMDBEntities.Entry(group).State == EntityState.Detached)
  {
      maMDBEntities.Groups.Attach(group);
  }
  </code></pre>
  
  <p>but now I sometimes get this error:</p>
  
  <blockquote>
    <p>An entity object cannot be referenced by multiple instances of IEntityChangeTracker.</p>
  </blockquote>
  
  <p>Was using <code>Attach()</code> an incorrect solution from the first place?</p>