title: Updating an Object's List Property in Entity Framework 4.3 - Code First, N-Tier
body: <p>In an n-tier scenario, how is the data layer supposed to update List properties of an object in EF 4.3?</p>
  
  <p>Let's say we have this class:</p>
  
  <pre><code>public class Foo
  {
    public int Id { get; set; }
    public string Name { get; set; }
    public List&lt;Bar&gt; Bars { get; set; }
  }
  </code></pre>
  
  <p>This works well as far as saving/updating Id and Name, but the Bars property is ignored.</p>
  
  <pre><code>protected void SaveChanges(Foo foo)
  {
    this.Database.Entry&lt;Foo&gt;(foo).State = GetState(foo);
    this.Database.SaveChanges();
  }
  </code></pre>
  
  <p>Since the original context (that retrieved Foo) is no longer in memory, how should the data layer deal with saving updates to the Bars property? How does EF know which Bar items have been removed, which have been updated, and which have been added?</p>
  
  <p>Note: I could loop through each Bar item and compare it to the original, but I'm guessing EF isn't supposed to work that way. That seems tedious and incorrect.</p>