System.TypeLoadException Could not load type 'Microsoft.EntityFrameworkCore.Query.RelationalQueryContextFactory'

1

I have written basic simple query which was working before when I was using .net core 2.2 (I have used linq2db.EntityFrameworkCore)

projectContext.DocumentAnnotation.ToLinqToDBTable().InsertWithIdentity(() => new DocumentAnnotation { Name = name, ParentId = parentId }))

after upgrade It to .net core 3.0 I am getting below error.

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()

My DocumentAnnotation class is as below.

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

2 Answers

1

We have released new version of linq2db.EntityFrameworkCore. Starting from 2.0 library supports EntityFrameworkCore 3.0

answered on Stack Overflow Oct 11, 2019 by Svyatoslav Danyliv
0

My bad.

Seems .Net core 3 is not yet supported by linq2db.EntityFrameworkCore.

Seems no option other than going back to old or wait.

Reference: https://github.com/linq2db/linq2db.EntityFrameworkCore/issues/18

answered on Stack Overflow Oct 5, 2019 by Anonymous Creator

User contributions licensed under CC BY-SA 3.0