Repository navigation
Auto-merge forward rel-10.7 → dev - #26283
Merged
Merged
Conversation
Resolve #26281 Remove the tenant ID from `AbpDbContext.GetCompiledQueryCacheKey()` and keep the data filter states in the key.
…d/rel-10.7-to-dev-86
Contributor
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
7 open findings
UseLoggerFactory(null)will throw (EF Core checks for non-null). If the intent is to disable… · New The unit of work is begun but never completed. In ABP, disposing an uncompleted UoW typically… · New Same issue as the other seeding path: the UoW is not completed. If the UoW wraps a transaction,… · New EF CoreDbSetproperties are typically initialized with= null!;to avoid nullable warnings… · New Non-nullable field_efServiceProvideris assigned inConfigureServicesbut not initialized in… · New With nullable reference types enabled,Namebeing non-nullable but not initialized will generate… · New If nullable reference types are enabled, assigningnulltoIModelwill warn/fail. Prefer… · New
What changed in this PR
Updates ABP’s EF Core compiled-query cache key behavior to improve reuse across tenants, with accompanying tests and documentation explaining when tenant-specific cache keys are still required.
Changes:
- Changed
AbpDbContext.GetCompiledQueryCacheKey()to exclude tenant id and only include global filter states. - Added new EF Core test modules/DbContexts/entities validating compiled query reuse and tenant-dependent translation scenarios.
- Updated migration guide and data-filtering docs to explain the behavioral change and recommended overrides.
| File | Description |
|---|---|
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/TenantDependentTranslation_Tests.cs | Adds regression test for tenant-isolated cache keys when custom translation embeds tenant into SQL. |
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/TenantDependentTranslationTestRow.cs | Adds entity used by tenant-dependent translation tests. |
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/TenantDependentTranslationTestModule.cs | Adds test module wiring/seeding for tenant-dependent translation scenario. |
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/TenantDependentTranslationTestDbContext.cs | Adds DbContext with a translated DbFunction and tenant-aware cache key override. |
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/QueryCompilationCounter.cs | Adds helper to count EF query compilation events. |
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/CompiledQueryCache_WithoutDbFunction_Tests.cs | Adds coverage for behavior when DbFunction mapping is disabled. |
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/CompiledQueryCache_Tests.cs | Adds coverage for behavior when DbFunction mapping is enabled. |
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/CompiledQueryCacheTestRow.cs | Adds entity used by compiled-query cache tests. |
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/CompiledQueryCacheTestModuleWithoutDbFunction.cs | Adds test module variant without DbFunction mapping. |
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/CompiledQueryCacheTestModuleBase.cs | Adds shared EF setup, seeding, and compilation-count logging for tests. |
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/CompiledQueryCacheTestModule.cs | Adds test module variant with DbFunction mapping. |
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/CompiledQueryCacheTestDbContext.cs | Adds DbContext used by compiled-query cache tests. |
| framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/DataFiltering/CompiledQueryCache/CompiledQueryCacheTestBase.cs | Adds the main test logic validating cache key reuse across tenants/filter states. |
| framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs | Changes the default compiled-query cache key to exclude tenant id. |
| docs/en/release-info/migration-guides/abp-10-7.md | Documents the change and how to opt-in to tenant-specific cache keying for custom translations. |
| docs/en/framework/infrastructure/data-filtering.md | Updates guidance around HasTranslation and cache key composition. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| Configure<AbpDbContextOptions>(options => options.Configure(configuration => | ||
| { | ||
| configuration.UseSqlite(); | ||
| configuration.DbContextOptions.UseLoggerFactory(null); |
| dbContext.Database.ExecuteSqlInterpolated( | ||
| $@"INSERT INTO Rows (Id, TenantId, IsDeleted, Name) | ||
| VALUES ({Guid.NewGuid()}, {row.TenantId}, {row.Deleted}, {row.Name})"); | ||
| } |
| dbContext.Database.ExecuteSqlInterpolated( | ||
| $@"INSERT INTO CustomTranslationRows (Id, OwnerTenantId, Name) | ||
| VALUES ({Guid.NewGuid()}, {row.OwnerTenantId}, {row.Name})"); | ||
| } |
|
|
||
| public class CompiledQueryCacheTestDbContext : AbpDbContext<CompiledQueryCacheTestDbContext> | ||
| { | ||
| public DbSet<CompiledQueryCacheTestRow> Rows { get; set; } |
| }; | ||
|
|
||
| private readonly AbpUnitTestSqliteDatabase _database = new(); | ||
| private ServiceProvider _efServiceProvider; |
| { | ||
| public Guid? TenantId { get; set; } | ||
| public bool IsDeleted { get; set; } | ||
| public string Name { get; set; } |
| var queryTag = Guid.NewGuid().ToString(); | ||
| var counter = GetRequiredService<QueryCompilationCounter>(); | ||
| var before = counter.Count; | ||
| IModel sharedModel = null; |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## dev #26283 +/- ##
==========================================
- Coverage 50.50% 50.41% -0.10%
==========================================
Files 3845 3858 +13
Lines 136106 136396 +290
Branches 10342 10369 +27
==========================================
+ Hits 68745 68763 +18
- Misses 65301 65562 +261
- Partials 2060 2071 +11 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Automated forward merge of
rel-10.7intodev.