title: Entity Framework 4 Loading Reference Exception
body: <p>I'm having troubles loading the reference to a parent object in Entity Framework 4. Due to Lazy Loading the reference to the parent object (Condition) is not loaded on the child object (DiscountLevel), so I try to load it with:</p>
  
  <pre><code>if(!this.ConditionReference.IsLoaded) this.ConditionReference.Load();
  </code></pre>
  
  <p>But this throws the following exception: </p>
  
  <blockquote>
    <p>the entity reference could not be loaded because it is not attached to an objectcontext</p>
  </blockquote>
  
  <p>So if I try to attach the existing child object (DiscountLevel) to the Object Context (and then load the parent reference afterwards):</p>
  
  <pre><code>context.AttachTo("tblDiscountLevel", this);
  </code></pre>
  
  <p>I get the following exception:</p>
  
  <blockquote>
    <p>An object with the same key already exists in the ObjectStateManager. The existing object is in the Detached state. An object can only be added to the ObjectStateManager again if it is in the added state.</p>
  </blockquote>
  
  <p>I feel like I'm doing something wrong in the first place, but I can't figure out what. So every help on this topic is very appreciated. Let me know if you need additional information!</p>