日期:2014-05-20 浏览次数:20945 次
//中间表 public class Middle { [Key] public int MiddleID { set; get; } [ForeignKey("Student")] public int StudentID { set; get; } [ForeignKey("Subject")] public int SubjectID { set; get; } public virtual Student Student { set; get; } public virtual Subject Subject { set; get; } } //学生表 public class Student { [Key] public int StudentID { set; get; } [Column("StudentName")] public string StudentName { set; get; } [Column("BeiZhu")] public string BeiZhu { set; get; } public virtual ICollection<Middle> Middle { set; get; } } //科目表 public class Subject { [Key] public int SubjectID { set; get; } [Column("SubjectName")] public string SubjectName { set; get; } public virtual ICollection<Middle> Middle { set; get; } }