【问题标题】:System.TypeLoadException Could not load type 'Microsoft.EntityFrameworkCore.Query.RelationalQueryContextFactory'System.TypeLoadException 无法加载类型“Microsoft.EntityFrameworkCore.Query.RelationalQueryContextFactory”
【发布时间】:2019-10-05 14:53:20
【问题描述】:

我已经编写了基本的简单查询,在我使用 .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()

我的 DocumentAnnotation 类如下。

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; }
    }

【问题讨论】:

    标签: c# entity-framework asp.net-core entity-framework-core linq2db


    【解决方案1】:

    我们发布了新版本的 linq2db.EntityFrameworkCore。 从 2.0 库开始支持 EntityFrameworkCore 3.0

    【讨论】:

      【解决方案2】:

      我的错。

      linq2db.EntityFrameworkCore 似乎还不支持 .Net core 3。

      除了回到旧的或等待之外似乎别无选择。

      参考: https://github.com/linq2db/linq2db.EntityFrameworkCore/issues/18

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-09-28
        • 2016-11-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-30
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多