title: ASP.MVC ModelBinding Behaviour
body: <p>This one has me stumped, despite the numerous posts on here.</p>
  
  <p>The scenario is a basic MVC(2) web application with simple CRUD operations. Whenever the edit form is submitted and the UpdateModel() called, an exception is thrown:</p>
  
  <blockquote>
    <p>System.Data.Linq.ForeignKeyReferenceAlreadyHasValueException was unhandled by user code</p>
  </blockquote>
  
  <p>This occurs against a DropDownList value which is a foreign key on the entity table. However, there is another DropDownList list on the form, representing another foreign key, which does not throw the error (unsurprisingly). Changing the property values manually inside the Edit Action:</p>
  
  <pre><code>Recipe recipe = repository.GetRecipe(int.Parse(formValues["recipeid"]));
  recipe.CategoryId = Convert.ToInt32(formValues["CategoryId"].ToString());
  recipe.Page = int.Parse(formValues["Page"].ToString());
  recipe.PublicationId=Convert.ToInt32(formValues["PublicationId"].ToString());
  </code></pre>
  
  <p>Allows the CategoryId and Page properties to be updated, and then the error is thrown on the PublicationId. All of the referential integrity is checked an the same in the db and the dbml.</p>
  
  <p>Any light shed on this would be most welcome.</p>