【发布时间】:2019-10-17 19:58:41
【问题描述】:
我正在使用“Asp.Net Core 2.0”并安装了 nuget 包“Microsoft.EntityFrameworkCore”版本“3.0.0-preview5.19227.1”,当我想使用 IQuarable 函数时,出现上述错误。
public partial class Wfuser
{
public Wfuser()
{
UserRole = new HashSet<UserRole>();
}
public int IdUser { get; set; }
public string FullName { get; set; }
public string UserName { get; set; }
public virtual Userauth Userauth { get; set; }
public virtual ICollection<UserRole> UserRole { get; set; }
}
public class NormalUser : IUser
{
public string UserName { get; set; }
public string Password { get; set; }
public NormalUser(string UserName, string Password)
{
this.UserName = UserName;
this.Password = Password;
}
public Wfuser CurrentWFUSER { get; set; }
public string ErrorMessage { get; set; }
ITTMSContext db;
public bool IsAuthenticated { get; set; }
public UserProfile Profile { get; set; }
public bool Authenticate()
{
db = new ITTMSContext();
CurrentWFUSER = db.Wfuser.FirstOrDefault(u => u.UserName == UserName);
int idUser = CurrentWFUSER.IdUser;
}
}
完整的错误信息是:
'无法确定'JContainer'类型的导航属性'JToken.Parent'表示的关系。手动配置关系,或使用“[NotMapped]”属性或使用“OnModelCreating”中的“EntityTypeBuilder.Ignore”忽略此属性。
【问题讨论】:
标签: c# entity-framework-core aspnetcoretemplatepack