2026-12-01 - π’ On Track
Native LINQ for the MongoDB EF Core Provider
Headline: native EF LINQ is about 33% faster with 68% less memory than today's wrapped driver path, and up to 6Γ faster on common queries. It is about as fast as the raw driver, and often faster, while being a full ODM.
The problem. Until now the provider has run queries by handing them to the MongoDB C# driver's own LINQ provider. That got v1 to GA quickly. But it is slow and uses a lot of memory, and it needs the driver to understand EF Core semantics. Writing an EF Core LINQ provider from scratch would normally take person-years of skilled work.
The project. Arthur Vickers used Claude Code to build a first-class ("native") EF Core LINQ provider for MongoDB. The driver is now used only for low-level database access. The provider itself handles LINQ translation to MQL, BSON rendering and object materialization.
Architecture.
- Compile time (once per query shape, cached by EF): preprocess β translate LINQ to a logical IR β postprocess the projection.
- Gate: ClassifyNativeDisposition decides which path a query takes, under the rule "decline, never guess."
- Native path: lower to aggregation stages ($match, $lookup, $project), render a BSON template with parameter placeholders, and compile a one-pass shaper that streams straight off the cursor.
- Fallback path: the previous driver-LINQ path with its DOM-based shaper.
- Every execution: bind parameters into a clone of the template, let the driver run the aggregate, and materialize objects directly from the cursor.
How it was built.
- A feasibility spike with benchmarks came first. It said yes to a native provider but no to dropping the driver entirely.
- Next came a detailed plan split into ten sub-projects, built using sub-agents. This top-down, "waterfall" approach slipped after a few weeks: scope crept and an agent notes file grew to 594 KB. A reset followed that filed more than 100 issues and ran the rest of the work in a Scrum-like way.
- At the peak, 3β6 top-level agents worked in parallel. Repeated reviews by fresh-context agents in specific areas (13 specialized reviewers) ran until they found only nits, followed by passes to tighten up code quality.
Size and status.
- The PR is about +160K / β10K lines. About 70% of the added lines are tests (β115K test, β45K product).
- Thousands of EF spec tests and thousands of new functional tests pass.
- A reviewer guide (docs/native-query-reviewer-guide.md) ships with the PR.
- The PR is not yet merged. Human review remains the bottleneck.
- AI estimates the work at about 200 person-weeks of human effort. The human time spent was about 8 person-weeks.
Performance summary
Benchmarks cover 70+ query shapes and compare three paths: the raw driver alone, EF on the wrapped driver LINQ, and EF native LINQ. Both execution time and allocations were measured.
Native vs. wrapped driver LINQ (78 queries, async rows excluded):
β β Typical query β Breadth β Best cases β Time β 33% faster β faster in 77 of 78 β ProjectOwnedCollectionSelect 6.2Γ (268β43 ms); ProjectOwnedReference 4.8Γ; MediumWholeEntity 2.7Γ β
β Memory β 68% less β less in 78 of 78 β ProjectOwnedCollectionSelect 25.4Γ less (110β4.3 MB); ProjectOwnedReference 13.1Γ; WideWholeEntity 12.9Γ (348β27 MB) β
Native vs. driver alone (73 queries, tracking rows excluded):
β β Typical query β Notes β Time β 13% faster (87% of the raw driver's time) β Range is 43% (GroupByJoinedKey, ExplicitJoin) to 108% (ProjectJoinedEntity). Simple filter, paging and by-ID queries are at parity. β
β Memory β 49% less β None of the 73 use more than 25% more. GroupBy shapes do best (e.g. GroupByOwnedHighCardinality uses 15% of the driver's memory).
2026-12-01 - No confidence status provided
Native LINQ for the MongoDB EF Core Provider
Headline: native EF LINQ is about 33% faster with 68% less memory than today's wrapped driver path, and up to 6Γ faster on common queries. It is about as fast as the raw driver, and often faster, while being a full ODM.
The problem. Until now the provider has run queries by handing them to the MongoDB C# driver's own LINQ provider. That got v1 to GA quickly. But it is slow and uses a lot of memory, and it needs the driver to understand EF Core semantics. Writing an EF Core LINQ provider from scratch would normally take person-years of skilled work.
The project. Arthur Vickers used Claude Code to build a first-class ("native") EF Core LINQ provider for MongoDB. The driver is now used only for low-level database access. The provider itself handles LINQ translation to MQL, BSON rendering and object materialization.
Architecture.
- Compile time (once per query shape, cached by EF): preprocess β translate LINQ to a logical IR β postprocess the projection.
- Gate: ClassifyNativeDisposition decides which path a query takes, under the rule "decline, never guess."
- Native path: lower to aggregation stages ($match, $lookup, $project), render a BSON template with parameter placeholders, and compile a one-pass shaper that streams straight off the cursor.
- Fallback path: the previous driver-LINQ path with its DOM-based shaper.
- Every execution: bind parameters into a clone of the template, let the driver run the aggregate, and materialize objects directly from the cursor.
How it was built.
- A feasibility spike with benchmarks came first. It said yes to a native provider but no to dropping the driver entirely.
- Next came a detailed plan split into ten sub-projects, built using sub-agents. This top-down, "waterfall" approach slipped after a few weeks: scope crept and an agent notes file grew to 594 KB. A reset followed that filed more than 100 issues and ran the rest of the work in a Scrum-like way.
- At the peak, 3β6 top-level agents worked in parallel. Repeated reviews by fresh-context agents in specific areas (13 specialized reviewers) ran until they found only nits, followed by passes to tighten up code quality.
Size and status.
- The PR is about +160K / β10K lines. About 70% of the added lines are tests (β115K test, β45K product).
- Thousands of EF spec tests and thousands of new functional tests pass.
- A reviewer guide (docs/native-query-reviewer-guide.md) ships with the PR.
- The PR is not yet merged. Human review remains the bottleneck.
- AI estimates the work at about 200 person-weeks of human effort. The human time spent was about 8 person-weeks.
Performance summary
Benchmarks cover 70+ query shapes and compare three paths: the raw driver alone, EF on the wrapped driver LINQ, and EF native LINQ. Both execution time and allocations were measured.
Native vs. wrapped driver LINQ (78 queries, async rows excluded):
β β Typical query β Breadth β Best cases β Time β 33% faster β faster in 77 of 78 β ProjectOwnedCollectionSelect 6.2Γ (268β43 ms); ProjectOwnedReference 4.8Γ; MediumWholeEntity 2.7Γ β
β Memory β 68% less β less in 78 of 78 β ProjectOwnedCollectionSelect 25.4Γ less (110β4.3 MB); ProjectOwnedReference 13.1Γ; WideWholeEntity 12.9Γ (348β27 MB) β
Native vs. driver alone (73 queries, tracking rows excluded):
β β Typical query β Notes β Time β 13% faster (87% of the raw driver's time) β Range is 43% (GroupByJoinedKey, ExplicitJoin) to 108% (ProjectJoinedEntity). Simple filter, paging and by-ID queries are at parity. β
β Memory β 49% less β None of the 73 use more than 25% more. GroupBy shapes do best (e.g. GroupByOwnedHighCardinality uses 15% of the driver's memory).
2026-11-26 - No confidence status provided
Initial implementation is complete. All queries we have tests for that previously passed with the driver-based LINQ now pass with native LINQ. Perf is much improved. For more information, see https://www.youtube.com/watch?v=2RuFKqSVV88
There is no known delivery date. That depends on code review, which is out of my hands.
2026-07-29 - No confidence status provided
No project update provided