【发布时间】:2015-07-28 17:46:59
【问题描述】:
我了解以下代码在主体和从属实体之间创建“一对一关系”。
不过,我想问一下:
是否可以在不包括依赖实体中的导航属性的情况下创建一对一关系?
-
如果是,那我应该如何重写下面的代码?
public class Student { [Key] public int Id { get; set; } public string FullName { get; set; } public StudentReport StudentReport { get; set; } } public class StudentReport { [Key, ForeignKey("Student")] public int Id { get; set; } public string RollNumber { get; set; } public string StudentType { get; set; } public Student Student { get; set; } }
【问题讨论】:
标签: entity-framework ef-code-first code-first