无法确定类型 'JContainer' 的导航 属性 'JToken.Parent' 表示的关系
Unable to determine the relationship represented by navigation property 'JToken.Parent' of type 'JContainer'
我正在使用 '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' 忽略此 属性
我终于自己找到了。
正如错误消息所提到的,我应该在不在我的 table 字段中的属性之前添加一个 [NotMapped]
属性。
我正在使用 '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' 忽略此 属性我终于自己找到了。
正如错误消息所提到的,我应该在不在我的 table 字段中的属性之前添加一个 [NotMapped]
属性。