title: Why does EF populate with null values a Entity that does not exist in Database?
body: <p>When I try to retrieve a entity from database that have relationships, but in fact, all relationships are null, the EntityFramework populates the relationship with null values, instead of setting relationship to null.</p>
  
  <p>Why does it happens? There's any way to avoid this pattern?</p>
  
  <p>Example:</p>
  
  <pre><code>public class Entity{
      public Int32 ID {get;set;}
  
      public Relationship relationship {get;set;}
  }
  
  public class Relationship{
      public Int32 ID {get;set;}
  
      public Int32 property {get;set;}
  }  
  </code></pre>
  
  <p>If I try, without having a Relationship inside the database:</p>
  
  <pre><code>Entity entity = context.entities.Include("relationship").SingleOrDefault( e =&gt; e.ID == id);
  </code></pre>
  
  <p>I can access entity.relationship without triggering a NullReferenceException, but the property "property" is null.</p>
  
  <p>Thanks,</p>
  
  <p>Igor</p>