有很多像我这样的问题,但我认为我做的一切都是正确的,我没有看到这里的错误是代码:
public class Card
{
public int Id { get; set; }
public string AccountNumber { get; set; } // or string ??
public decimal TotalFunds { get; set; }
public virtual User User { get; set; }
}
public class User
{
public int Id { get; set; }
public string Username { get; set; }
public string AuthCode { get; set; }
public string SessionKey { get; set; }
public string AccessToken { get; set; }
public virtual Card Card { get; set; }
//public virtual UserType UserType { get; set; }
public virtual ICollection<Vehicle> RentedVehicles { get; set; }
public User()
{
this.RentedVehicles = new HashSet<Vehicle>();
}
public string Email { get; set; }
}
而且我犯了一个错误Unable to determine the principal end of an association between the types 'VehicleRental.Models.Card' and 'VehicleRental.Models.User'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.
,我已经这样做了好几次(与虚拟属性的连接 1:1 并且它总是有效),但现在我被这个问题困住了。任何帮助将不胜感激。