-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add precompiled query generation to the dbcontext optimize command #33747
base: main
Are you sure you want to change the base?
Conversation
881f8e9
to
b840cc6
Compare
620a708
to
0eaf687
Compare
Condition="'$(PublishAot)'=='true'" | ||
Properties="Configuration=$(Configuration);Platform=$(Platform);EFOptimizeContext=false;PublishAot=false" /> | ||
Properties="Configuration=$(Configuration);Platform=$(Platform);PublishAot=false;_EFGenerationStage=$(_EFGenerationStage)" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to always pass Configuration
and Platform
? Should we pass other properties?
This target has the same Inputs and Outputs as CoreCompile to run only if CoreCompile isn't going to be skipped --> | ||
<Target Name="_EFPrepareForCompile" | ||
DependsOnTargets="_EFProcessGeneratedFiles" | ||
Condition="'$(EFOptimizeContext)'=='true'" | ||
Condition="'$(_EFGenerationStage)'==''" | ||
Inputs="$(MSBuildAllProjects); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way of determining whether CoreCompile
is going to be skipped other than duplicating its inputs and outputs?
|
||
MSBuildLocator.RegisterDefaults(); | ||
// TODO: pass through properties | ||
var workspace = MSBuildWorkspace.Create(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What properties should we pass through from the MsBuild invocation?
3616c0f
to
3d181c1
Compare
…unless a single one is specified Fixes #33558
Just to say that this is on my list to review... Will work up to it in the next few days. |
Ok. Just note that the longer you take to review the more code will need to be reviewed 😉 |
That's a pretty effective way to speed up a code review :) |
Also adds publish integration for precompiled queries and combines it with compiled model generation.
For the compiled model and precompiled queries to be generated when publishing with NativeAOT the only action needed is to reference
Microsoft.EntityFrameworkCore.Tasks
from all projects containing aDbContext
or a query.For solutions where specifying the startup project is necessary,
EFStartupProject
should be set.EFOptimizeContext
can be set totrue
to enable code generation outside of NativeAOT.EFScaffoldModelStage
andEFPrecompileQueriesStage
can be set to eitherpublish
orbuild
to control at what stage will the code be generated. Any other value will disable the corresponding generation (in case the code is generated manually usingdotnet ef dbcontext optimize
)If there's more than one context and
DbContextName
is not set, then the compiled model will be generated for all of them.EFTargetNamespace
andEFOutputDir
can be used to further fine-tune the generation.Fixes #33103
Fixes #33558