Query precompilation is all-or-nothing per project; allow writing the interceptors of the queries that did precompile
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start with DbContextOperations.PrecompileQueries and PrecompiledQueryCodeGenerator.ProcessSyntaxTree, the two entry points named in the issue. Trace how generation errors are collected and how per-query state is written, then inspect the precompilation tests and the documented non-NativeAOT behavior. Done means an opt-in can write interceptors for successful queries, report failures, and avoid leaving partial query regions when generation fails.
Written by the indexing model from the issue text.
Description
DbContextOperations.PrecompileQueries throws if precompilationErrors.Count > 0, so one query that cannot be precompiled discards the interceptors of every other query in the project. The docs ("Precompiled queries without NativeAOT") say the command "will generate a compiled model and interceptors for queries which could be precompiled", which is not what 10.0.11 does.
In a real application (SentenceStudio: ~600 queries, 4 projects) this means no project gets any interceptors until the last query is rewritten. With EF Core 10.0.11 plus the precompiler fixes now on main, 394 queries precompile and 202 do not; the stock tool writes 0 of the 394.
A second, smaller problem blocks a simple "continue on error": PrecompiledQueryCodeGenerator.ProcessSyntaxTree appends to the file's _code, _namespaces and _unsafeAccessors while it generates a query. If generation throws after #region QueryN was written, the catch records the error and continues, leaving that half-written region in the file.
What we did locally (design-time only) to measure the rest of the app:
- In
ProcessSyntaxTree, snapshot_code,_namespacesand_unsafeAccessorsbefore each query and restore them in thecatch. - In
DbContextOperations.PrecompileQueries, an opt-in that reports the errors as warnings and writes the files.
Ask: an option (for example --allow-partial / <EFPrecompileQueriesAllowPartial>) that writes the precompilable queries and reports the rest, at least when not publishing NativeAOT. Under NativeAOT the remaining queries still throw "Query wasn't precompiled", so the option is most useful for (a) the non-AOT startup benefit the docs describe and (b) incremental migration of a large codebase to NativeAOT.
Versions: EF Core 10.0.11, .NET SDK 11.0.100-rc.2.
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.5k
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 182
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/efcore
-
customer-reported
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
GroupBy element `OrderBy(...).First()`/`MaxBy` over an owned type mapped to its own table fails to translatePossibly taken @cincuranet claimed this today. Openarea-groupby area-query
Difficulty 4/5 3-5 days Newbie friendliness 25/100
dotnet/efcore#39833 · 1 assignee ·
Maintainers usually reply within 2 days
-
SQLite: Polygon.Length translates to GLength, which returns 0Possibly taken @cincuranet claimed this today. Openarea-query area-sqlite
Difficulty 3/5 1-2 days Newbie friendliness 45/100
dotnet/efcore#39826 · 1 assignee ·
Maintainers usually reply within 2 days
-
Migration lock with LockReleaseBehavior.Transaction doesn't prevent concurrent migrations since per-migration transactionsPossibly taken @AndriySvyryd claimed this 1 day ago. Openarea-migrations
dotnet/efcore#39824 · 1 assignee ·
Maintainers usually reply within 2 days
-
Querying a TPC base type with a JSON complex property throwsPossibly taken @cincuranet claimed this 1 day ago. Openarea-query
Difficulty 4/5 3-5 days Newbie friendliness 22/100
dotnet/efcore#39814 · 1 assignee ·
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
SubtitleEdit/subtitleedit#17247 ·
Maintainers usually reply within 1 day
-
Restore test cleanup fails on Windows when restored files are read-onlyPossibly taken @JamBalaya56562 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
duplicati/duplicati#8046 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Bundles Documentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pyrevitlabs/pyRevit#4285 ·
Maintainers usually reply within 1 day