我无法弄清楚为什么这会导致 EF 错误:保存在 EF 中时列名“User_UserId”无效。
这是我的模型:
[DataContract(IsReference = true)]
public class User
{
[Key]
[DataMember]
public virtual Guid UserId { get; set; }
[DataMember]
public virtual string Username { get; set; }
[DataMember]
public virtual string Password { get; set; }
[DataMember]
public virtual string Email { get; set; }
[DataMember]
public virtual ICollection<FriendList> FriendLists { get; set; }
}
[DataContract(IsReference = true)]
public class FriendList
{
[Key]
[DataMember]
public virtual Guid FriendListId { get; set; }
[DataMember]
[ForeignKey("User")]
public virtual Guid UserId { get; set; }
[DataMember]
public virtual User User { get; set; }
[DataMember]
[ForeignKey("FriendUser")]
public virtual Guid FriendUserId { get; set; }
[DataMember]
public virtual User FriendUser { get; set; }
}
基本上,它与拥有好友列表的用户的一对多关系。