我正在使用Entity Framwork 6.0.2,我正在尝试使用User和UserLogged与Id建立一对一的关系。我正在使用EntityTypeConfiguration(Fluent API),但我没有得到。请参阅下面的代码:
public class User
{
public Int64 UserId { get; set; }
public String Name { get; set; }
public String Surname { get; set; }
public String Email { get; set; }
public String Login { get; set; }
public String Password { get; set; }
public DateTime RegisterDate { get; set; }
}
public class UserLogged
{
public Int64 UserId { get; set; }
public String ComputerName { get; set; }
public String AddressIp { get; set; }
public String AddressMac { get; set; }
public virtual User User { get; set; }
}
public class UserLoggedMap : EntityTypeConfiguration<UserLogged>
{
public UserLoggedMap()
{
this.HasKey(u => u.UserId);
this.HasRequired(u => u.User).WithOptional(u => u.UserId);
}
}
非常感谢。