拥有这两个实体:
public partial class Title
{
public int Id { get; set; }
public string Description { get; set; }
}
public partial class Person
{
public int Id { get; set; }
public string Description { get; set; }
public virtual Title Title { get; set; }
}
如何映射关系以便在Person中需要Title?
答案 0 :(得分:0)
您可以使用Fluent API
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Person>()
.HasRequired(a => a.Title);
}