From 5575719ec85122036bc6ea750b9c6781112660ec Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 4 Mar 2026 03:05:20 +0000
Subject: [PATCH 1/8] Initial plan
From 6562d8785722435a28968be1b487018743185b4a Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 4 Mar 2026 03:11:22 +0000
Subject: [PATCH 2/8] Remove EFOptimizeContext property from EF targets
EFScaffoldModelStage and EFPrecompileQueriesStage are sufficient to
control whether code generation is enabled. EFOptimizeContext is no
longer needed as a separate enablement flag.
- Remove EFOptimizeContext checks from _EFGenerateFilesAfterBuild and
_EFGenerateFilesBeforePublish target conditions
- Update dotnet-ef to pass stage=none properties instead of
EFOptimizeContext=false when building during dbcontext optimize
- Update comments and README to remove EFOptimizeContext references
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
---
src/EFCore.Tasks/README.md | 2 +-
.../Microsoft.EntityFrameworkCore.Tasks.targets | 9 ++++-----
src/dotnet-ef/RootCommand.cs | 2 +-
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/EFCore.Tasks/README.md b/src/EFCore.Tasks/README.md
index e23d373b089..ffefb4bbaa1 100644
--- a/src/EFCore.Tasks/README.md
+++ b/src/EFCore.Tasks/README.md
@@ -4,7 +4,7 @@ This package should be referenced by the project containing the derived `DbConte
## Usage
-Install the package into your project, set `true` and then run build normally.
+Install the package into your project and then run build or publish normally. The code generation is controlled by the `$(EFScaffoldModelStage)` and `$(EFPrecompileQueriesStage)` properties, which can be set to either `publish` or `build` to control at what stage the code will be generated. Any other value will disable the corresponding generation.
If the startup project is different from the current project it needs to be specified: `..\Startup\Startup.csproj`
diff --git a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets
index 1032f4edbea..7af7b535fe8 100644
--- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets
+++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets
@@ -18,9 +18,8 @@
+ Condition="'$(_EFGenerationStage)'=='' And ('$(EFScaffoldModelStage)'=='build' Or '$(EFPrecompileQueriesStage)'=='build')">
+ Condition="'$(_EFGenerationStage)'=='' And ('$(EFScaffoldModelStage)'=='publish' Or '$(EFPrecompileQueriesStage)'=='publish')">
a == "--no-scaffold");
- startupProject.Build(skipOptimization ? new[] { "/p:EFOptimizeContext=false" } : null);
+ startupProject.Build(skipOptimization ? ["/p:EFScaffoldModelStage=none", "/p:EFPrecompileQueriesStage=none"] : null);
Reporter.WriteInformation(Resources.BuildSucceeded);
}
From 229dac400f5b51018855fe3bea6583d30fd8818c Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 4 Mar 2026 03:12:31 +0000
Subject: [PATCH 3/8] Remove unused _EFPublishAOT property from dependency
propagation target
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
---
.../buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets
index 7af7b535fe8..5db3675a363 100644
--- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets
+++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets
@@ -209,7 +209,7 @@ For Publish:
Projects="@(_MSBuildProjectReferenceExistent)"
Targets="_EFGenerateFilesBeforePublish"
BuildInParallel="$(BuildInParallel)"
- Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);%(_MSBuildProjectReferenceExistent.SetPlatform);%(_MSBuildProjectReferenceExistent.SetTargetFramework);_EFPublishAOT=true"
+ Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration);%(_MSBuildProjectReferenceExistent.SetPlatform);%(_MSBuildProjectReferenceExistent.SetTargetFramework)"
Condition="'%(_MSBuildProjectReferenceExistent.BuildReference)' == 'true' and '@(ProjectReferenceWithConfiguration)' != '' "
ContinueOnError="$(ContinueOnError)"
SkipNonexistentTargets="true"
From aac0035b735d48d137220d0c7d5d8fd93d0af7c0 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Wed, 4 Mar 2026 04:50:10 +0000
Subject: [PATCH 4/8] Restore PublishAOT condition and usage comment per review
feedback
- Revert usage comment to mention PublishAOT
- Keep PublishAOT/_EFPublishAOT condition in _EFGenerateFilesBeforePublish
- Restore _EFPublishAOT=true in _EFPrepareDependenciesForPublishAOT
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
---
.../Microsoft.EntityFrameworkCore.Tasks.targets | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets
index 5db3675a363..cce9e958962 100644
--- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets
+++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets
@@ -18,7 +18,7 @@