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
Post a Comment