title: Entity Framework won't detect changes of navigation properties
body: <p>I'm having trouble with detecting changes of a navigation property:</p>
  <p>My testing model looks like this:</p>
  <pre><code>public class Person
  {
      public int Id { get; set; }
  
      public string Name { get; set; }
  
      public virtual Address Address { get; set; }
  }
  
  public class Address
  {
      public int Id { get; set; }
  
      public string Name { get; set; }
  }
  </code></pre>
  <p>I've created and saved an object of type <code>Person</code> with both <code>Name</code> and <code>Address</code> properties assigned. My problem is that if I fetch the <code>Person</code> object back from the database and I change the <code>Address</code> property (ex. to null) then EF doesn't detect the change!</p>
  <p>My code is this:</p>
  <pre><code>using (var ctx = new EFContext())
  {
      Person p = ctx.People.First();
      // p.Address IS NOT NULL!
      p.Address = null;
      var entry = ctx.Entry(p);
  }
  </code></pre>
  <p>Why is <code>entry.State</code> <strong><code>Unchanged</code></strong> ?</p>
  <p><strong>Edit:</strong> If I call <code>SaveChanges</code>, the record is saved correctly (the <code>Address</code> become null)!</p>
  <p><strong>Edit 2:</strong> I've created the foreign key property as billy suggested. If I inspect the <code>Person</code> object in Visual Studio, the <code>State</code> is <code>Modified</code>. If I don't stop with the debugger inspecting the object's values, the state is <code>Unchanged</code>!</p>
  <p><strong>Edit 3:</strong> Loading the <code>Person</code> object using <code>ctx.People.Include(x =&gt; x.Address).First();</code> solves the problem. Is there a way to avoid calling <code>Include</code> and continue to modify the <code>Address</code> property instead of the <code>AddressId</code> one?</p>