c# - Entity Framework - many to many related data loads into the navigation property collection, properties contain nulls except for the Id -


i have many many relationship below:

public class student {   public int studentid { get; set; }    public string studentname { get; set; }   public virtual icollection<course> courses { get; set; } }  public class course {   public int courseid { get; set; }    public string coursename { get; set; }   public virtual icollection<student> students { get; set; } } 

the database migration creates junction table named studentcourse.

using eager loading load data:

var student = context.students      .include(x => x.courses)      .firstordefault();  

my observations:

  • student.courses.count = 5
  • student.courses[0].courseid = 1
  • student.courses[0].coursename = null

why courses.coursename property null?


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -