title: Update Foreign key (entity) with entity framework V1
body: <p>I have a small ASP.NET MVC application with the following entity objects:</p>
  
  <p>Person</p>
  
  <ul>
  <li>PersonId</li>
  <li>Name (string)</li>
  <li>FirstName (string)</li>
  <li>Country (Country)</li>
  </ul>
  
  <p>Country</p>
  
  <ul>
  <li>CountryId</li>
  <li>Name</li>
  </ul>
  
  <p>I can add and delete the entity's this works fine. I can also update name, firstname.
  But how can i update the country property with another country.</p>
  
  <p>i was trying</p>
  
  <pre><code>p.Country = (from c in db.Country 
               where c.CountryId == countryId 
               select c).First();
  </code></pre>
  
  <p>but this fires an exception {"An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key."}"</p>
  
  <p>even before i call SaveChanges on the datacontext.</p>
  
  <p>Can someone explaind how i can update this property?</p>
  
  <p>kind regards
  Dieter</p>