我想使用EF Code First创建两个实体之间的双向一对一关系。但是以下代码让我遇到了麻烦。你认为我应该怎么做?
public class User
{
public string ID { get; set; }
public string LastName { get; set; }
public string Password { get; set; }
public string FirstName { get; set; }
public int ProfileID { get; set; }
public Profile Profile { get; set; }
}
public class Profile
{
public int UserID { get; set; }
public User User { get; set; }
public int ProfileID { get; set; }
public string ProfileName { get; set; }
public DateTime CreateDate { get; set; }
public DateTime LastUpdateDate { get; set; }
}
我希望在两个实体中都有导航属性和外键。
这会导致错误。在Fluent Mapping API中该怎么做才能使其正常工作?