title: EF 4.1 SaveChanges not updating navigation or reference properties
body: <p>I'm using code first and can add records without a problem. The database is created properly and is seeded without any problems. But calling SaveChanges() in my Edit action only updates the entity, not any of the navigation or reference properties.</p>
  
  <p>A simplified version of my model:</p>
  
  <pre><code>public class Contact : IMyBaseObject
  {
      public Contact()
      {
         this.Delete = false;
         this.ContactTypes = new HashSet&lt;ContactType&gt;();
      }
  
      public int Id {get; set;}
  
      public string Name {get;set;}
  
      public bool Delete {get;set;}
  
      public virtual ICollection&lt;ContactType&gt; ContactTypes { get; set; }
  
      public virtual USState USState { get; set; }
  
  }
  
  public class ContactType : MyBaseObject
  {
      public ContactType()
      {
      }
  
      public int Id {get; set;}
  
      public string Name {get;set;}
  
      public virtual ICollection&lt;Contact&gt; Contacts {get;set;}
  }
  
  public abstract class Territory : MyBaseObject
  {
      public int Id {get; set;}
  
      public string Name {get;set;}
  
      public string Code {get;set;}
  }
  
  public class USState : Territory
  {
      public USState()
      {
      }
  
      // Navigation properties
      public virtual ICollection&lt;Contact&gt; Contacts { get; set; }
  }
  </code></pre>
  
  <p>I won't include the code, but I do have some custom model binding going on. My Edit action (using MVC 3) was not being populated with the ContactType or USState properties. The binding is properly returning a fully populated Contact object with the correct values from the form.</p>
  
  <p>If I understand EF 4.1 properly, I should only have to do the following to persist changes to the database when saving my Contact object:</p>
  
  <pre><code>if(ModelState.IsValid)
  {
      context.Entry(contact).State = EntryState.Modified;
      context.SaveChanges();
  }
  </code></pre>
  
  <p>However, only primitive properties are being updated when I do that. I have left out a few things in the above example: I'm using a transaction, a try catch block, and checking if it's a new record.</p>
  
  <p>I have used SQL Profiler and can confirm that the update queries for the ContactType and Territory tables are <strong>not</strong> being sent to the database server.</p>
  
  <p>The State properties of my navigation and reference properties are Modified, but I have also tried manually setting that:</p>
  
  <pre><code>    context.Entry(contact).Collections("ContactTypes").EntityEntry.State = EntityState.Modified;
      context.Entry(contact).Reference("USState").EntityEntry.State = EntityState.Modified;
  </code></pre>
  
  <p>I could be mistaken, but I'm pretty sure my code was working under CTP5.</p>
  
  <p>Any ideas? At this point, I'm not sure how I should approach debugging this.</p>
  
  <p>Thanks, Steve</p>