System.TypeLoadException 无法加载类型 'Microsoft.EntityFrameworkCore.Query.RelationalQueryContextFactory'
System.TypeLoadException Could not load type 'Microsoft.EntityFrameworkCore.Query.RelationalQueryContextFactory'
我已经编写了基本的简单查询,它在我使用 .net core 2.2(我使用过 linq2db.EntityFrameworkCore)之前是有效的
projectContext.DocumentAnnotation.ToLinqToDBTable().InsertWithIdentity(() => new DocumentAnnotation { Name = name, ParentId = parentId }))
升级到 .net core 3.0 后出现以下错误。
System.TypeLoadException
HResult=0x80131522
Message=Could not load type 'Microsoft.EntityFrameworkCore.Query.RelationalQueryContextFactory' from assembly 'Microsoft.EntityFrameworkCore.Relational, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
Source=linq2db.EntityFrameworkCore
StackTrace:
at LinqToDB.EntityFrameworkCore.LinqToDBForEFToolsImplDefault.GetCurrentContext(IQueryable query)
at LinqToDB.EntityFrameworkCore.LinqToDBForEFTools.ToLinqToDBTable[T](DbSet`1 dbSet)
at MyProjectBusiness.Repositories.Projects.DocumentAnnotationRepository.SaveAnnotation(Nullable`1 parentId, String name) in E:\MyProject\MyProjectBusiness\MyProjectBusiness\Repositories\Projects\DocumentAnnotationRepository.cs:line 39
at MyProjectBusiness.Repositories.Projects.DocumentAnnotationRepository.GetDocumentAnnotation(Nullable`1[] parentIds, Boolean isMultiPage) in E:\MyProject\MyProjectBusiness\MyProjectBusiness\Repositories\Projects\DocumentAnnotationRepository.cs:line 69
at MyProjectWeb.api.Controllers.DocumentAnnotationController.Annotations(JObject documentData) in E:\MyProject\MyProjectweb\MyProjectWeb\Controllers\api\Project\Document\DocumentAnnotationController.cs:line 29
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
我的文档注释class如下。
public partial class DocumentAnnotation
{
public DocumentAnnotation()
{
DocumentAnnotationValue = new HashSet<DocumentAnnotationValue>();
DocumentAnnotationValueMultiPage = new HashSet<DocumentAnnotationValueMultiPage>();
ChildDocumentAnnotation = new HashSet<DocumentAnnotation>();
}
public int Id { get; set; }
public string Name { get; set; }
public int? ParentId { get; set; }
public bool? IsMultiPage { get; set; }
public virtual DocumentAnnotation Parent { get; set; }
public virtual ICollection<DocumentAnnotationValue> DocumentAnnotationValue { get; set; }
public virtual ICollection<DocumentAnnotationValueMultiPage> DocumentAnnotationValueMultiPage { get; set; }
public virtual ICollection<DocumentAnnotation> ChildDocumentAnnotation { get; set; }
}
我的错。
似乎 linq2db.EntityFrameworkCore 还不支持 .Net core 3。
除了回到旧的或等待之外似乎别无选择。
参考:
https://github.com/linq2db/linq2db.EntityFrameworkCore/issues/18
我们发布了 linq2db.EntityFrameworkCore 的新版本。
从 2.0 库开始支持 EntityFrameworkCore 3.0
我已经编写了基本的简单查询,它在我使用 .net core 2.2(我使用过 linq2db.EntityFrameworkCore)之前是有效的
projectContext.DocumentAnnotation.ToLinqToDBTable().InsertWithIdentity(() => new DocumentAnnotation { Name = name, ParentId = parentId }))
升级到 .net core 3.0 后出现以下错误。
System.TypeLoadException
HResult=0x80131522
Message=Could not load type 'Microsoft.EntityFrameworkCore.Query.RelationalQueryContextFactory' from assembly 'Microsoft.EntityFrameworkCore.Relational, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
Source=linq2db.EntityFrameworkCore
StackTrace:
at LinqToDB.EntityFrameworkCore.LinqToDBForEFToolsImplDefault.GetCurrentContext(IQueryable query)
at LinqToDB.EntityFrameworkCore.LinqToDBForEFTools.ToLinqToDBTable[T](DbSet`1 dbSet)
at MyProjectBusiness.Repositories.Projects.DocumentAnnotationRepository.SaveAnnotation(Nullable`1 parentId, String name) in E:\MyProject\MyProjectBusiness\MyProjectBusiness\Repositories\Projects\DocumentAnnotationRepository.cs:line 39
at MyProjectBusiness.Repositories.Projects.DocumentAnnotationRepository.GetDocumentAnnotation(Nullable`1[] parentIds, Boolean isMultiPage) in E:\MyProject\MyProjectBusiness\MyProjectBusiness\Repositories\Projects\DocumentAnnotationRepository.cs:line 69
at MyProjectWeb.api.Controllers.DocumentAnnotationController.Annotations(JObject documentData) in E:\MyProject\MyProjectweb\MyProjectWeb\Controllers\api\Project\Document\DocumentAnnotationController.cs:line 29
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
我的文档注释class如下。
public partial class DocumentAnnotation
{
public DocumentAnnotation()
{
DocumentAnnotationValue = new HashSet<DocumentAnnotationValue>();
DocumentAnnotationValueMultiPage = new HashSet<DocumentAnnotationValueMultiPage>();
ChildDocumentAnnotation = new HashSet<DocumentAnnotation>();
}
public int Id { get; set; }
public string Name { get; set; }
public int? ParentId { get; set; }
public bool? IsMultiPage { get; set; }
public virtual DocumentAnnotation Parent { get; set; }
public virtual ICollection<DocumentAnnotationValue> DocumentAnnotationValue { get; set; }
public virtual ICollection<DocumentAnnotationValueMultiPage> DocumentAnnotationValueMultiPage { get; set; }
public virtual ICollection<DocumentAnnotation> ChildDocumentAnnotation { get; set; }
}
我的错。
似乎 linq2db.EntityFrameworkCore 还不支持 .Net core 3。
除了回到旧的或等待之外似乎别无选择。
参考: https://github.com/linq2db/linq2db.EntityFrameworkCore/issues/18
我们发布了 linq2db.EntityFrameworkCore 的新版本。 从 2.0 库开始支持 EntityFrameworkCore 3.0