title: Entity Framework - many to many related data loads into the navigation property collection, properties contain nulls except for the Id
body: <p>I have the many to many relationship below:</p>
  
  <pre><code>public class Student {
    public int StudentId { get; set; } 
    public string StudentName { get; set; }
    public virtual ICollection&lt;Course&gt; Courses { get; set; }
  }
  
  public class Course {
    public int CourseId { get; set; } 
    public string CourseName { get; set; }
    public virtual ICollection&lt;Student&gt; Students { get; set; }
  }
  </code></pre>
  
  <p>The database migration creates a Junction Table named StudentCourse.</p>
  
  <p>Using Eager Loading to load the data:</p>
  
  <pre><code>var student = context.Students 
      .Include(x =&gt; x.Courses) 
      .FirstOrDefault(); 
  </code></pre>
  
  <p>My observations:</p>
  
  <ul>
  <li>student.Courses.count = 5</li>
  <li>student.Courses[0].CourseId = 1</li>
  <li>student.Courses[0].CourseName = <strong>null</strong></li>
  </ul>
  
  <p>Why is the Courses.CourseName property null?</p>