有人可以指出我错在哪里!
我创建了2个简单的类,具有多对多的关系.工作正常,所有表都正确填充.除非我尝试并重温任何学生课程,否则不会返回...
public partial class Student
{
public Student()
{
Courses = new HashSet<Course>();
}
public int StudentID { get; set; }
[StringLength(50)]
[Required]
public string FirstName { get; set;}
[StringLength(50)]
[Required]
public string LastName {get; set;}
public DateTime? Enroled {get;set;}
public ICollection<Course> Courses { get; set; }
}
public class Course
{
public Course()
{
Students = new HashSet<Student>();
}
public int CourseID { get; set; }
[StringLength(30)]
[Required]
public string CourseTitle { get; set; }
[StringLength(255)]
public string …Run Code Online (Sandbox Code Playgroud)