我的表名是具有列名的Grades升级引用的值,它将是表中的主键值之一。Grades-同一表- 我尝试像下面的代码那样做
public class Grades
{
public int Id { get; set; }
public string Name { get; set; }
public Grades UpGrade { get; set; }
public int UpGradeId { get; set; }
}
答案 0 :(得分:0)
[ForeignKey]属性对自引用FK的效果应该与常规ForeignKeys
一样好public class Grades
{
public int Id { get; set; }
public string Name { get; set; }
[ForeignKey("UpGradeId")]
public Grades UpGrade { get; set; }
public int UpGradeId { get; set; }
}