嗨我有一个简单的EF 4.1代码第一个模型的问题。EF 4.1双向一对一问题
我有一个双向链接的班级人员和班级调查。该数据库模型是正确的,但我总是得到这样的错误:
Unable to determine the principal end of an association between the types 'DAL.Models.Survey' and 'DAL.Models.Person'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.
类人
[Key]
public Guid Id { get; set; }
[Required]
public string FirstName { get; set; }
[Required]
public string LastName { get; set; }
[Required]
public string Email { get; set; }
public virtual Survey Survey { get; set; }
类调查
[Key]
public Guid Id { get; set; }
public bool IsFinished { get; set; }
public virtual Person Person { get; set; }
的DataContext:
modelBuilder.Entity<Survey>().HasRequired(s => s.Person).WithOptional().WillCascadeOnDelete(true);
谁能帮助请
这是不可能的。 – Nealv 2011-05-20 12:55:53