title: How can entities be easily updated? (EF Code First, MVC3)
body: <p>I thought I had this all figured out, but I'm hitting a brick wall.</p>
  
  <p>Client sends in an object, my controller checks if user has right to edit, then proceeds to update the entity in the database. (along with any navigational property the object has).<br>
  <strong>My problem is, that I can't seem to get it work...</strong></p>
  
  <p>I tried</p>
  
  <pre><code>var obj = context.Recipes.SingleOrDefault(o=&gt;o.ID == id);
  UpdateModel(obj);
  </code></pre>
  
  <p>But I got a "model cannot be updated" exception.<br>
  So I tried a different approach, putting Recipe r into the parameter list (and let the model binder do the work) and call</p>
  
  <pre><code>context.Recipes.Attach(r); 
  </code></pre>
  
  <p>but that leaves things on "Unchanged", so <code>context.SaveChanges()</code> does nothing.</p>
  
  <p>Is there a simple solution without me having to write <code>obj.SomeProperty = r.SomeProperty</code> for EVERY property on my object?</p>
  
  <p><strong>Bonus question:</strong> if my entity has a navigational property (collection) I obviously add the new ones sent in (with <code>ID == 0</code>), but how do I know which one to delete? Can I leverage EF's Change Tracking somewhere here?</p>
  
  <p>For both questions: should there be a magic "compare this object with this object, and then save" method?</p>