title: Entity Framework child objects not populating
body: <p>I have a simple model which when I run the website in the debugger the entity framework does not correctly populate the model.</p>
  
  <p>The model is simple:</p>
  
  <pre><code>public class Team
  {
      /// &lt;summary&gt;
      ///     Constructor required for the EntityFramework to create the object.
      /// &lt;/summary&gt;
      private Team()
      {            
      }
  
      public Team(string name, ApplicationUser owner)
      {
          Name = name;
          Owner = owner;
      }
  
      [Required]
      public int Id { get; private set; }
  
      [Required]
      public string Name { get; private set; }
  
      [Required]
      public ApplicationUser Owner { get; private set; }
  
      [Required]
      public List&lt;TeamMembership&gt; Members { get; set; }
  }
  
  
  public class TeamMembership
  {
      /// &lt;summary&gt;
      ///     Constructor for the EntityFramework
      /// &lt;/summary&gt;
      private TeamMembership()
      {
      }
  
      public TeamMembership(ApplicationUser user, MembershipStatus status)
      {
          User = user;
          Status = status;
      }
  
      [Required]
      public ApplicationUser User { get; private set; }
  
      [Required]
      public MembershipStatus Status { get; set; }
  
      [Required]
      public int Id { get; private set; }
  }
  </code></pre>
  
  <p>Where <code>ApplicationUser</code> is the default class generated by the ASP MVC 5 membership infrastructure.</p>
  
  <p>When I run my tests (Specflow), which create a new LocalDb database with a unique id for each test and runs the migrations on that db,  then the entity framework correctly populates my Team and the Owner.</p>
  
  <p>However when I run the website and try and interact with the application then my Team is not fully populated, because the Owner is <code>null</code> and <code>Members</code> is not populated.  But the owner ID is set correctly in the database and the query seems ok.  The queries executed during the test and the running of the app seem the same.</p>
  
  <p>Why might this be and how might I start to debug the issue?</p>
  
  <p>I feel like I am missing something simple.</p>