简体   繁体   English

ASP.NET Boilerplate V7.x 不适用于 EF Core 6.x 的编译模型

[英]ASP.NET Boilerplate V7.x not working with compiled models for EF Core 6.x

EF Core 6 provides a feature called "Compiled Models" for better query performance (10x faster) but ABP V7.x cannot run compiled models. EF Core 6 提供了一项称为“编译模型”的功能,以实现更好的查询性能(快 10 倍),但 ABP V7.x 无法运行编译模型。 It throw the following exception:它抛出以下异常:

Entity 'Edition' has a global query filter defined and is the required end of a relationship with the entity 'EditionFeatureSetting'.实体“Edition”定义了一个全局查询过滤器,并且是与实体“EditionFeatureSetting”的关系的必需结束。 This may lead to unexpected results when the required entity is filtered out.当所需的实体被过滤掉时,这可能会导致意外的结果。 Either configure the navigation as optional, or define matching query filters for both entities in the navigation.将导航配置为可选,或者为导航中的两个实体定义匹配的查询过滤器。 See https://go.microsoft.com/fwlink/?linkid=2131316 for more information.有关详细信息,请参阅https://go.microsoft.com/fwlink/?linkid=2131316 System.InvalidOperationException: The entity type 'Edition' has a query filter configured. System.InvalidOperationException:实体类型“版本”配置了查询过滤器。 Compiled model can't be generated, because query filters are not supported.无法生成已编译的 model,因为不支持查询过滤器。 at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpRuntimeModelCodeGenerator.Create(IEntityType entityType, CSharpRuntimeAnnotationCodeGeneratorParameters parameters) at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpRuntimeModelCodeGenerator.CreateEntityType(IEntityType entityType, IndentedStringBuilder mainBuilder, IndentedStringBuilder methodBuilder, SortedSet`1 namespaces, String className, Boolean nullable) at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpRuntimeModelCodeGenerator.GenerateEntityType(IEntityType entityType, String namespace, String className, Boolean nullable) at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpRuntimeModelCodeGenerator.GenerateModel(IModel model, CompiledModelCodeGenerationOptions options) at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CompiledModelScaffolder.ScaffoldModel(IModel model, String在 Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpRuntimeModelCodeGenerator.Create(IEntityType entityType, CSharpRuntimeAnnotationCodeGeneratorParameters 参数) 在 Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpRuntimeModelCodeGenerator.CreateEntityType(IEntityType entityType, IndentedStringBuilder mainBuilder, IndentedStringBuilder methodBuilder, SortedSet`1 命名空间, String className, Z27226C864BAC7459A55B48EDBAC7454A55B48ED nullable) at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpRuntimeModelCodeGenerator.GenerateEntityType(IEntityType entityType, String namespace, String className, Boolean nullable) at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpRuntimeModelCodeGenerator.GenerateModel(IModel model, CompiledModelCodeGenerationOptions options) at Microsoft.EntityFrameworkCore .Scaffolding.Internal.CompiledModelScaffolder.ScaffoldModel(IModel model,字符串 outputDir, CompiledModelCodeGenerationOptions options) at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.Optimize(String outputDir, String modelNamespace, String contextTypeName) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OptimizeContextImpl(String outputDir, String modelNamespace, String contextType) at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OptimizeContext.<>c__DisplayClass0_0.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) The entity type 'Edition' has a query filter configured. outputDir, CompiledModelCodeGenerationOptions options) 在 Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.Optimize(String outputDir, String modelNamespace, String contextTypeName) 在 Microsoft.EntityFrameworkCore.Design.OperationExecutor.OptimizeContextImpl(String outputDir, String modelNamespace, String contextType) 在 Microsoft。 EntityFrameworkCore.Design.OperationExecutor.OptimizeContext.<>c__DisplayClass0_0.<.ctor>b__0() at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action) 实体类型“Edition”配置了查询过滤器。 Compiled model can't be generated, because query filters are not supported.无法生成已编译的 model,因为不支持查询过滤器。

Please help and support this problem, because compiled models is very very important for query performance.请帮助和支持这个问题,因为编译模型对于查询性能非常重要。

Thanks谢谢

The exception is not caused by ABP.该异常不是由 ABP 引起的。 Your EF context has at least one query filter configured.您的 EF 上下文至少配置了一个查询过滤器。 Compiled models do not support any query filters at this time, although it is on the backlog for a future release (see this GitHub issue ).编译模型目前不支持任何查询过滤器,尽管它在未来版本的积压工作中(请参阅此 GitHub 问题)。

The only options for the moment are to forego query filtering or forego compiled models.目前唯一的选择是放弃查询过滤或放弃编译模型。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM