0
是否可以映射以下方案?实体框架代码优先:实体分割
数据表
学生
+ ID:整数PK
+名称:VARCHAR(200)
类
+ ID:整数PK
+学生ID:FK
+ CourseID:FK
+ EnrollmentDate:日期时间
课程
+ ID:整数PK
+名称:VARCHAR(200)
我想的表来映射下面的实体。
public class Student
{
[Key]
public int ID {get;set;}
public string Name {get;set;}
public virtual ICollection<Class> Classes {get;set;}
}
public class Class
{
[Key]
public int ID {get;set;}
public Student Student {get;set;}
public DateTime EnrollmentDate {get;set;}
public string Name {get;set;} // this comes from the Courses data table
}