1

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

2 回答 2

1

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

于 2019-10-11T09:02:56.633 回答
0

我的错。

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

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

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

于 2019-10-05T19:11:25.037 回答