我编写了基本的简单查询,该查询在使用.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; }
}
答案 0 :(得分:1)
我们发布了 linq2db.EntityFrameworkCore 的新版本。 从2.0库开始支持EntityFrameworkCore 3.0
答案 1 :(得分:0)
我不好。
似乎linq2db.EntityFrameworkCore尚不支持.Net core 3。
似乎没有其他选择,只能恢复原状或等待。
参考: https://github.com/linq2db/linq2db.EntityFrameworkCore/issues/18