Adopt Weasel IDatabaseCleaner<T> and BatchedQuery EF Core APIs (#2473, #2478)#2492
Merged
jeremydmiller merged 1 commit intomainfrom Apr 9, 2026
Conversation
…ion (#2473, #2478) Issue #2473 – IDatabaseCleaner<TContext> / IInitialData<TContext>: - Add database_cleaner_tests.cs demonstrating IDatabaseCleaner<ItemsDbContext> registered via services.AddDatabaseCleaner<T>() and used in tests to replace manual DELETE FROM / schema-drop cleanup code. - Add SeedItemsForTests implementing IInitialData<ItemsDbContext> to show the recommended seed-data pattern with ResetAllDataAsync(). Issue #2478 – Weasel BatchedQuery codegen infrastructure: - Add BatchedLoadEntityFrame: SyncFrame that queues a QuerySingle() into a shared BatchedQuery instead of calling DbContext.FindAsync, enabling future multi-entity loads in a single round trip. - Add CreateBatchQueryFrame: inserts a shared BatchedQuery variable that BatchedLoadEntityFrame instances can share. - Add ExecuteBatchQueryFrame: executes the batch and awaits each entity Task. - Add batch_query_tests.cs with integration tests demonstrating CreateBatchQuery() for loading two entities, a list, and mixed single+list in one round trip, plus unit tests for the three new codegen frame types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Apr 11, 2026
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.
Summary
Closes #2473 and #2478.
#2473 – IDatabaseCleaner<TContext> in EF Core integration tests
Adopts Weasel 8.13.0's
IDatabaseCleaner<TContext>andIInitialData<TContext>APIs to replace ad-hoc manual cleanup code in integration tests.database_cleaner_tests.cs– new integration-test file demonstrating:services.AddDatabaseCleaner<ItemsDbContext>()(singleton, discovers tables fromDbContext.Model, generates FK-safe deletion SQL:TRUNCATE CASCADEon PostgreSQL,DELETE FROMon SQL Server)services.AddInitialData<ItemsDbContext, SeedItemsForTests>()for seed data that re-runs afterResetAllDataAsync()DeleteAllDataAsync()(clears all rows) andResetAllDataAsync()(clears then re-seeds)#2478 – Weasel BatchedQuery codegen infrastructure
Adds the code-generation frames and integration tests for Weasel's
BatchedQueryAPI, which batches multiple EF CoreSELECTqueries into a single database round trip.BatchedLoadEntityFrame–SyncFramethat enqueues abatch.QuerySingle(context.Set<T>().Where(…))into a sharedBatchedQueryinstead of callingDbContext.FindAsync. Participates in a shared batch when aCreateBatchQueryFrameis upstream.CreateBatchQueryFrame– inserts avar batchQuery = context.CreateBatchQuery()variable that downstream load frames share.ExecuteBatchQueryFrame– issuesawait batchQuery.ExecuteAsync(ct)and then awaits each pending entityTask.batch_query_tests.cs– integration tests against SQL Server showing:QuerySinglecalls in one round tripQuery<T>list loading in a batchTest plan
EfCoreTestsproject builds cleanly (dotnet build --framework net9.0)database_cleaner_usage_testsintegration tests pass against SQL Server (requiresdocker compose up -d)batch_query_testsintegration tests pass against SQL Serverbatched_load_entity_frame_codegen_testsunit tests pass without infrastructure🤖 Generated with Claude Code