From 5e696685b4fb22e30e7f2d979e7751be097bc030 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 21:06:05 +0000 Subject: [PATCH 01/11] Apply remaining changes Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .agents/output/issue-38317-triage.md | 182 +++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 .agents/output/issue-38317-triage.md diff --git a/.agents/output/issue-38317-triage.md b/.agents/output/issue-38317-triage.md new file mode 100644 index 00000000000..e94d57ce55c --- /dev/null +++ b/.agents/output/issue-38317-triage.md @@ -0,0 +1,182 @@ +# AI Triage + +The below is an AI-generated analysis and may contain inaccuracies. + +## Summary + +This report is about `dotnet ef` / publish-time integration failing for a NativeAOT‑targeted project that uses the new precompiled‑queries feature (EF Core 10). The reported error is: + +> Unable to create a 'DbContext' of type 'AnalystDbContext'. The exception 'The type initializer for '\' threw an exception.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728 + +The user's csproj snippet (most of the markup was eaten by GitHub markdown rendering) indicates `PublishAot=true` and that the `Microsoft.EntityFrameworkCore.GeneratedInterceptors` namespace has been added to `$(InterceptorsNamespaces)` — i.e. the precompiled queries / NativeAOT integration described at https://learn.microsoft.com/en-us/ef/core/performance/nativeaot-and-precompiled-queries is enabled. The scaffold comment in the code confirms the provider is `Microsoft.EntityFrameworkCore.Sqlite`. + +The phrase `The type initializer for '' threw an exception` means the **module initializer** of the user's compiled application assembly threw when EF's design‑time stack reflection‑loaded that assembly in order to instantiate the `DbContext` (the design‑time tooling first does an `Assembly.Load` of the project's output, and the CLR then runs the assembly's `` `.cctor`). The two libraries most likely to be responsible for a `` initializer in this scenario are: + +1. `SQLitePCLRaw.bundle_e_sqlite3` — registers the native SQLite provider from a `[ModuleInitializer]` and will throw if the matching native `e_sqlite3` library can't be located in the probing paths used by `dotnet ef` (e.g. RID‑specific assets that are present only after publish for a specific RID, or trimmed/AOT‑published output being re‑loaded by the non‑AOT `dotnet ef` host). +2. The `Microsoft.EntityFrameworkCore.GeneratedInterceptors` file generated by the precompiled queries feature — it lives in the user's assembly and is exercised the moment the assembly is loaded. + +Without the actual stack trace and inner exception we can't be certain which of the two is throwing. + +## What's missing from the report + +The bug report is essentially un‑actionable as filed: + +- The **Stack traces** block is empty. The inner exception of `TypeInitializationException` is exactly what's needed to root‑cause this. +- The **Verbose output** block is empty. Re‑running with `dotnet ef ... -v` (or `dotnet publish ... -v:diag /p:EFOptimizeContext=true`) would normally include the inner exception. +- The full `csproj` was mangled by GitHub's markdown (the `<...>` elements were dropped). Please paste it inside a fenced ` ```xml ... ``` ` block. +- The **Database provider** and **Target framework** fields are blank. + +Please attach the full stack trace (including all inner exceptions) and the raw `.csproj` so this can be properly diagnosed. + +## Likely workarounds + +While we wait for the diagnostics above, the following workarounds typically unblock this class of failures. Try them in order: + +### 1. Provide an `IDesignTimeDbContextFactory` + +Adding a design‑time factory takes EF's design‑time machinery off the "build the application's service provider" code path, which avoids most module‑initializer / startup‑order surprises: + +```csharp +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; + +public class AnalystDbContextFactory : IDesignTimeDbContextFactory +{ + public AnalystDbContext CreateDbContext(string[] args) + { + var options = new DbContextOptionsBuilder() + .UseSqlite("Data Source=sample.db") + .Options; + + return new AnalystDbContext { DbPath = "sample.db" }; + } +} +``` + +(See https://learn.microsoft.com/en-us/ef/core/cli/dbcontext-creation#from-a-design-time-factory) + +### 2. Disable the automatic build‑time `dbcontext optimize` + +The publish failure happens because `dotnet publish` automatically runs `dbcontext optimize --precompile-queries --nativeaot` as a build target. You can opt out of that and run it manually instead: + +```xml + + false + +``` + +Then, when you actually want to refresh the precompiled artifacts: + +```bash +dotnet ef dbcontext optimize --precompile-queries --nativeaot +``` + +### 3. Move the `DbContext` (and the model types) to a non‑AOT class library + +The cleanest separation for the experimental NativeAOT flow today is to keep the `DbContext` and entity types in a class library that does **not** have `true`. The executable project still references the class library and is published with NativeAOT; design‑time tools then load the library (which has no AOT‑specific module initializer fallout). This also avoids re‑loading an AOT‑trimmed application assembly from `dotnet ef`'s own (non‑AOT) host. + +### 4. Verify the native SQLite asset is reachable from the `dotnet ef` host + +If the inner exception turns out to be `DllNotFoundException: e_sqlite3` (or similar), the `` cctor of `SQLitePCLRaw.bundle_e_sqlite3` is failing because the native lib hasn't been copied next to the loaded managed DLL. Two practical mitigations: + +- Run `dotnet build` (not just `dotnet publish` with a single RID) before invoking `dotnet ef` so that `runtimes//native/e_sqlite3.*` is restored under `bin///`. +- Add `` to your `Debug` build (or set it on the `dotnet ef` invocation via `--runtime`), so the native asset is staged where the EF design‑time host probes. + +### 5. As a temporary last resort — disable AOT for the design‑time build + +This is what `dotnet ef` itself attempts (`/p:PublishAot=false /p:EFOptimizeContext=false`). If your project does additional AOT‑specific work in `OnConfiguring` or in a static constructor of the `DbContext`, guard it so it doesn't run when invoked from the design‑time host, e.g. by checking for the `EFCORE_DESIGN` AppContext switch or the `IsDesignTime` static helpers documented at https://learn.microsoft.com/en-us/ef/core/cli/dbcontext-creation. + +## Likely duplicates / related + +- https://github.com/dotnet/efcore/issues/35494 – `efcore/NativeAOT: precompile queries throws UnreachableException exception` (open, `area-precompiled-queries`) +- https://github.com/dotnet/efcore/issues/37365 – `precompile queries throws UnreachableException exception` (open, `area-precompiled-queries`) +- https://github.com/dotnet/efcore/issues/35945 – `[AOT] dotnet ef dbcontext optimize --precompile-queries --nativeaot fails with error CS9137` (closed as duplicate, `area-aot`) +- https://github.com/dotnet/efcore/issues/35219 – `NullReferenceException when trying to optimize a DbContext with --nativeaot` (`area-aot`) +- https://github.com/dotnet/efcore/issues/36804 – `Optimize --nativeaot creates public accessors for internal types which fails to compile` (`area-aot`) +- https://github.com/dotnet/efcore/issues/35659 – `AOT Setup in .NET 8 On Lambda Fails` +- Tracking issue for the experimental feature: https://github.com/dotnet/efcore/issues/25009 (`Precompiled queries`) + +## Suggested classification + +- **Type**: Bug (pending repro/diagnostics confirmation) +- **Area labels**: `area-aot`, `area-precompiled-queries`, `area-sqlite` +- **Regression?**: Can't be determined without the inner exception. The NativeAOT + precompiled queries integration is itself a new EF Core 10 / experimental feature, so this is unlikely to represent a regression from a previously‑working scenario in EF Core 9 — it's more likely a "doesn't work yet" report against the experimental surface. + +## Minimal repro + +A genuine minimal repro requires the inner exception (so the right component can be reproduced). Below is the closest scaffold based purely on what's visible in the report — it mirrors the user's `AnalystDbContext` shape and turns on the same MSBuild knobs. **It has not been confirmed to reproduce the reported error** because the report does not include enough information to do so. + +
+minimal repro (unconfirmed) + +`Repro.csproj`: + +```xml + + + Exe + net10.0 + enable + true + $(InterceptorsNamespaces);Microsoft.EntityFrameworkCore.GeneratedInterceptors + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + +``` + +`Program.cs`: + +```csharp +using Microsoft.EntityFrameworkCore; + +await using var ctx = new AnalystDbContext { DbPath = "sample.db" }; +await ctx.Database.EnsureCreatedAsync(); + +public partial class AnalystDbContext : DbContext +{ + public string DbPath { get; set; } = "sample.db"; + + public virtual DbSet Warnings { get; set; } = null!; + + protected override void OnConfiguring(DbContextOptionsBuilder options) + => options.UseSqlite($"Data Source={DbPath}"); + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity(entity => + { + entity.HasKey(e => e.WRN_ID); + entity.Property(e => e.WRN_Category).HasColumnType("TEXT (100)"); + entity.Property(e => e.WRN_Column).HasColumnType("TEXT (5)"); + entity.Property(e => e.WRN_Impact).HasColumnType("TEXT (10)"); + entity.Property(e => e.WRN_Name).HasColumnType("TEXT (50)"); + entity.Property(e => e.WRN_Priority).HasColumnType("TEXT (10)"); + }); + } +} + +public partial class Warning +{ + public int WRN_ID { get; set; } + public string WRN_Category { get; set; } = null!; + public string WRN_Name { get; set; } = null!; + public string WRN_Priority { get; set; } = null!; + public string WRN_Impact { get; set; } = null!; + public string WRN_Notes { get; set; } = null!; + public string WRN_Column { get; set; } = null!; +} +``` + +Then: + +```bash +dotnet publish -r linux-x64 -c Release +``` + +
From e71aa277635c26a81be7ac3dc26278b3fff26a2c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 27 May 2026 23:44:02 +0000 Subject: [PATCH 02/11] Apply fix to Microsoft.EntityFrameworkCore.Tasks.targets and remove triage md Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .agents/output/issue-38317-triage.md | 182 ------------------ ...icrosoft.EntityFrameworkCore.Tasks.targets | 2 +- 2 files changed, 1 insertion(+), 183 deletions(-) delete mode 100644 .agents/output/issue-38317-triage.md diff --git a/.agents/output/issue-38317-triage.md b/.agents/output/issue-38317-triage.md deleted file mode 100644 index e94d57ce55c..00000000000 --- a/.agents/output/issue-38317-triage.md +++ /dev/null @@ -1,182 +0,0 @@ -# AI Triage - -The below is an AI-generated analysis and may contain inaccuracies. - -## Summary - -This report is about `dotnet ef` / publish-time integration failing for a NativeAOT‑targeted project that uses the new precompiled‑queries feature (EF Core 10). The reported error is: - -> Unable to create a 'DbContext' of type 'AnalystDbContext'. The exception 'The type initializer for '\' threw an exception.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728 - -The user's csproj snippet (most of the markup was eaten by GitHub markdown rendering) indicates `PublishAot=true` and that the `Microsoft.EntityFrameworkCore.GeneratedInterceptors` namespace has been added to `$(InterceptorsNamespaces)` — i.e. the precompiled queries / NativeAOT integration described at https://learn.microsoft.com/en-us/ef/core/performance/nativeaot-and-precompiled-queries is enabled. The scaffold comment in the code confirms the provider is `Microsoft.EntityFrameworkCore.Sqlite`. - -The phrase `The type initializer for '' threw an exception` means the **module initializer** of the user's compiled application assembly threw when EF's design‑time stack reflection‑loaded that assembly in order to instantiate the `DbContext` (the design‑time tooling first does an `Assembly.Load` of the project's output, and the CLR then runs the assembly's `` `.cctor`). The two libraries most likely to be responsible for a `` initializer in this scenario are: - -1. `SQLitePCLRaw.bundle_e_sqlite3` — registers the native SQLite provider from a `[ModuleInitializer]` and will throw if the matching native `e_sqlite3` library can't be located in the probing paths used by `dotnet ef` (e.g. RID‑specific assets that are present only after publish for a specific RID, or trimmed/AOT‑published output being re‑loaded by the non‑AOT `dotnet ef` host). -2. The `Microsoft.EntityFrameworkCore.GeneratedInterceptors` file generated by the precompiled queries feature — it lives in the user's assembly and is exercised the moment the assembly is loaded. - -Without the actual stack trace and inner exception we can't be certain which of the two is throwing. - -## What's missing from the report - -The bug report is essentially un‑actionable as filed: - -- The **Stack traces** block is empty. The inner exception of `TypeInitializationException` is exactly what's needed to root‑cause this. -- The **Verbose output** block is empty. Re‑running with `dotnet ef ... -v` (or `dotnet publish ... -v:diag /p:EFOptimizeContext=true`) would normally include the inner exception. -- The full `csproj` was mangled by GitHub's markdown (the `<...>` elements were dropped). Please paste it inside a fenced ` ```xml ... ``` ` block. -- The **Database provider** and **Target framework** fields are blank. - -Please attach the full stack trace (including all inner exceptions) and the raw `.csproj` so this can be properly diagnosed. - -## Likely workarounds - -While we wait for the diagnostics above, the following workarounds typically unblock this class of failures. Try them in order: - -### 1. Provide an `IDesignTimeDbContextFactory` - -Adding a design‑time factory takes EF's design‑time machinery off the "build the application's service provider" code path, which avoids most module‑initializer / startup‑order surprises: - -```csharp -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; - -public class AnalystDbContextFactory : IDesignTimeDbContextFactory -{ - public AnalystDbContext CreateDbContext(string[] args) - { - var options = new DbContextOptionsBuilder() - .UseSqlite("Data Source=sample.db") - .Options; - - return new AnalystDbContext { DbPath = "sample.db" }; - } -} -``` - -(See https://learn.microsoft.com/en-us/ef/core/cli/dbcontext-creation#from-a-design-time-factory) - -### 2. Disable the automatic build‑time `dbcontext optimize` - -The publish failure happens because `dotnet publish` automatically runs `dbcontext optimize --precompile-queries --nativeaot` as a build target. You can opt out of that and run it manually instead: - -```xml - - false - -``` - -Then, when you actually want to refresh the precompiled artifacts: - -```bash -dotnet ef dbcontext optimize --precompile-queries --nativeaot -``` - -### 3. Move the `DbContext` (and the model types) to a non‑AOT class library - -The cleanest separation for the experimental NativeAOT flow today is to keep the `DbContext` and entity types in a class library that does **not** have `true`. The executable project still references the class library and is published with NativeAOT; design‑time tools then load the library (which has no AOT‑specific module initializer fallout). This also avoids re‑loading an AOT‑trimmed application assembly from `dotnet ef`'s own (non‑AOT) host. - -### 4. Verify the native SQLite asset is reachable from the `dotnet ef` host - -If the inner exception turns out to be `DllNotFoundException: e_sqlite3` (or similar), the `` cctor of `SQLitePCLRaw.bundle_e_sqlite3` is failing because the native lib hasn't been copied next to the loaded managed DLL. Two practical mitigations: - -- Run `dotnet build` (not just `dotnet publish` with a single RID) before invoking `dotnet ef` so that `runtimes//native/e_sqlite3.*` is restored under `bin///`. -- Add `` to your `Debug` build (or set it on the `dotnet ef` invocation via `--runtime`), so the native asset is staged where the EF design‑time host probes. - -### 5. As a temporary last resort — disable AOT for the design‑time build - -This is what `dotnet ef` itself attempts (`/p:PublishAot=false /p:EFOptimizeContext=false`). If your project does additional AOT‑specific work in `OnConfiguring` or in a static constructor of the `DbContext`, guard it so it doesn't run when invoked from the design‑time host, e.g. by checking for the `EFCORE_DESIGN` AppContext switch or the `IsDesignTime` static helpers documented at https://learn.microsoft.com/en-us/ef/core/cli/dbcontext-creation. - -## Likely duplicates / related - -- https://github.com/dotnet/efcore/issues/35494 – `efcore/NativeAOT: precompile queries throws UnreachableException exception` (open, `area-precompiled-queries`) -- https://github.com/dotnet/efcore/issues/37365 – `precompile queries throws UnreachableException exception` (open, `area-precompiled-queries`) -- https://github.com/dotnet/efcore/issues/35945 – `[AOT] dotnet ef dbcontext optimize --precompile-queries --nativeaot fails with error CS9137` (closed as duplicate, `area-aot`) -- https://github.com/dotnet/efcore/issues/35219 – `NullReferenceException when trying to optimize a DbContext with --nativeaot` (`area-aot`) -- https://github.com/dotnet/efcore/issues/36804 – `Optimize --nativeaot creates public accessors for internal types which fails to compile` (`area-aot`) -- https://github.com/dotnet/efcore/issues/35659 – `AOT Setup in .NET 8 On Lambda Fails` -- Tracking issue for the experimental feature: https://github.com/dotnet/efcore/issues/25009 (`Precompiled queries`) - -## Suggested classification - -- **Type**: Bug (pending repro/diagnostics confirmation) -- **Area labels**: `area-aot`, `area-precompiled-queries`, `area-sqlite` -- **Regression?**: Can't be determined without the inner exception. The NativeAOT + precompiled queries integration is itself a new EF Core 10 / experimental feature, so this is unlikely to represent a regression from a previously‑working scenario in EF Core 9 — it's more likely a "doesn't work yet" report against the experimental surface. - -## Minimal repro - -A genuine minimal repro requires the inner exception (so the right component can be reproduced). Below is the closest scaffold based purely on what's visible in the report — it mirrors the user's `AnalystDbContext` shape and turns on the same MSBuild knobs. **It has not been confirmed to reproduce the reported error** because the report does not include enough information to do so. - -
-minimal repro (unconfirmed) - -`Repro.csproj`: - -```xml - - - Exe - net10.0 - enable - true - $(InterceptorsNamespaces);Microsoft.EntityFrameworkCore.GeneratedInterceptors - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - -``` - -`Program.cs`: - -```csharp -using Microsoft.EntityFrameworkCore; - -await using var ctx = new AnalystDbContext { DbPath = "sample.db" }; -await ctx.Database.EnsureCreatedAsync(); - -public partial class AnalystDbContext : DbContext -{ - public string DbPath { get; set; } = "sample.db"; - - public virtual DbSet Warnings { get; set; } = null!; - - protected override void OnConfiguring(DbContextOptionsBuilder options) - => options.UseSqlite($"Data Source={DbPath}"); - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - modelBuilder.Entity(entity => - { - entity.HasKey(e => e.WRN_ID); - entity.Property(e => e.WRN_Category).HasColumnType("TEXT (100)"); - entity.Property(e => e.WRN_Column).HasColumnType("TEXT (5)"); - entity.Property(e => e.WRN_Impact).HasColumnType("TEXT (10)"); - entity.Property(e => e.WRN_Name).HasColumnType("TEXT (50)"); - entity.Property(e => e.WRN_Priority).HasColumnType("TEXT (10)"); - }); - } -} - -public partial class Warning -{ - public int WRN_ID { get; set; } - public string WRN_Category { get; set; } = null!; - public string WRN_Name { get; set; } = null!; - public string WRN_Priority { get; set; } = null!; - public string WRN_Impact { get; set; } = null!; - public string WRN_Notes { get; set; } = null!; - public string WRN_Column { get; set; } = null!; -} -``` - -Then: - -```bash -dotnet publish -r linux-x64 -c Release -``` - -
diff --git a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets index cbf43363318..5c38efc16f9 100644 --- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets +++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets @@ -73,7 +73,7 @@ For Publish: Targets="OptimizeDbContext" BuildInParallel="$(BuildInParallel)" ContinueOnError="$(ContinueOnError)" - Properties="Configuration=$(Configuration);Platform=$(Platform);_EFGenerationStage=$(_EFGenerationStage)" /> + Properties="Configuration=$(Configuration);Platform=$(Platform);PublishAot=false;RuntimeIdentifier=;SelfContained=false;_EFGenerationStage=$(_EFGenerationStage)" /> From eca72cb6a5e6b61db1590218f4b980fe9ab38dd2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 01:03:59 +0000 Subject: [PATCH 03/11] Also clear RuntimeIdentifier/SelfContained on inner Build invocation for PublishAot 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 5c38efc16f9..60a2e2f5807 100644 --- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets +++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets @@ -67,7 +67,7 @@ For Publish: BuildInParallel="$(BuildInParallel)" ContinueOnError="$(ContinueOnError)" Condition="'$(PublishAot)'=='true'" - Properties="Configuration=$(Configuration);Platform=$(Platform);PublishAot=false;_EFGenerationStage=$(_EFGenerationStage)" /> + Properties="Configuration=$(Configuration);Platform=$(Platform);PublishAot=false;RuntimeIdentifier=;SelfContained=false;_EFGenerationStage=$(_EFGenerationStage)" /> Date: Thu, 28 May 2026 01:32:25 +0000 Subject: [PATCH 04/11] Make RID-clearing in inner _EFGenerateFiles MSBuild calls conditional on PublishAot Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../Microsoft.EntityFrameworkCore.Tasks.targets | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets index 60a2e2f5807..200b42810be 100644 --- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets +++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets @@ -61,19 +61,29 @@ For Publish: - + + + <_EFInnerBuildProperties>Configuration=$(Configuration);Platform=$(Platform);PublishAot=false;_EFGenerationStage=$(_EFGenerationStage) + <_EFInnerBuildProperties Condition="'$(PublishAot)'=='true'">$(_EFInnerBuildProperties);RuntimeIdentifier=;SelfContained=false + + + Properties="$(_EFInnerBuildProperties)" /> + Properties="$(_EFInnerBuildProperties)" /> From 57d16cbb8db61e15cb04d9c66099e3b41dc422a3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 03:41:12 +0000 Subject: [PATCH 05/11] Preserve RID and add InterceptorsNamespaces for AOT publish Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../Microsoft.EntityFrameworkCore.Tasks.props | 2 ++ .../Microsoft.EntityFrameworkCore.Tasks.targets | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.props b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.props index 8e96fccc3ab..fae4e77ef67 100644 --- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.props +++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.props @@ -8,6 +8,8 @@ publish publish * + + $(InterceptorsNamespaces);Microsoft.EntityFrameworkCore.GeneratedInterceptors diff --git a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets index 200b42810be..c77743dbc41 100644 --- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets +++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets @@ -84,6 +84,20 @@ For Publish: BuildInParallel="$(BuildInParallel)" ContinueOnError="$(ContinueOnError)" Properties="$(_EFInnerBuildProperties)" /> + + + From 3b798430c57f3d037fe66308e47c195d301463d7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 05:07:33 +0000 Subject: [PATCH 06/11] Always clear RID and unify third Build call per review feedback Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- ...icrosoft.EntityFrameworkCore.Tasks.targets | 23 +++++-------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets index c77743dbc41..88e911e25bd 100644 --- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets +++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets @@ -62,14 +62,8 @@ For Publish: - - <_EFInnerBuildProperties>Configuration=$(Configuration);Platform=$(Platform);PublishAot=false;_EFGenerationStage=$(_EFGenerationStage) - <_EFInnerBuildProperties Condition="'$(PublishAot)'=='true'">$(_EFInnerBuildProperties);RuntimeIdentifier=;SelfContained=false + + <_EFInnerBuildProperties>Configuration=$(Configuration);Platform=$(Platform);PublishAot=false;RuntimeIdentifier=;SelfContained=false;_EFGenerationStage=$(_EFGenerationStage) + Properties="Configuration=$(Configuration);Platform=$(Platform);PublishAot=$(PublishAot);RuntimeIdentifier=$(RuntimeIdentifier);SelfContained=$(SelfContained);AppendRuntimeIdentifierToOutputPath=$(AppendRuntimeIdentifierToOutputPath);_EFGenerationStage=$(_EFGenerationStage)" /> @@ -150,8 +141,6 @@ For Publish: - - Date: Thu, 28 May 2026 05:51:23 +0000 Subject: [PATCH 07/11] Always run first inner Build so non-AOT publish finds non-RID assembly Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets | 1 - 1 file changed, 1 deletion(-) diff --git a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets index 88e911e25bd..c1b86fe510a 100644 --- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets +++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets @@ -70,7 +70,6 @@ For Publish: Targets="Build" BuildInParallel="$(BuildInParallel)" ContinueOnError="$(ContinueOnError)" - Condition="'$(PublishAot)'=='true'" Properties="$(_EFInnerBuildProperties)" /> Date: Thu, 28 May 2026 06:53:54 +0000 Subject: [PATCH 08/11] Revert default generated interceptors namespace opt-in Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../buildTransitive/Microsoft.EntityFrameworkCore.Tasks.props | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.props b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.props index fae4e77ef67..8e96fccc3ab 100644 --- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.props +++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.props @@ -8,8 +8,6 @@ publish publish * - - $(InterceptorsNamespaces);Microsoft.EntityFrameworkCore.GeneratedInterceptors From a8eba436bdb485f8d1d3e8ec52f8bb9e2088bbba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 06:58:46 +0000 Subject: [PATCH 09/11] Simplify final rebuild to CallTarget Build Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../Microsoft.EntityFrameworkCore.Tasks.targets | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets index c1b86fe510a..d0cb7fecb19 100644 --- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets +++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets @@ -78,16 +78,8 @@ For Publish: ContinueOnError="$(ContinueOnError)" Properties="$(_EFInnerBuildProperties)" /> - - + + From 7241b189834f6443248dad2245f35cd94495b57a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 07:00:03 +0000 Subject: [PATCH 10/11] Clarify CallTarget uses current invocation properties 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 d0cb7fecb19..757f16f8be0 100644 --- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets +++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets @@ -78,7 +78,7 @@ For Publish: ContinueOnError="$(ContinueOnError)" Properties="$(_EFInnerBuildProperties)" /> - + From 0c83f882cd7eecd6dcf72b23103b5435a916c32f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 28 May 2026 23:20:07 +0000 Subject: [PATCH 11/11] Restore PublishAot-gated RID clearing in EF inner build flow Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com> --- .../Microsoft.EntityFrameworkCore.Tasks.targets | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets index 757f16f8be0..4ff9238fa41 100644 --- a/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets +++ b/src/EFCore.Tasks/buildTransitive/Microsoft.EntityFrameworkCore.Tasks.targets @@ -62,14 +62,16 @@ For Publish: - - <_EFInnerBuildProperties>Configuration=$(Configuration);Platform=$(Platform);PublishAot=false;RuntimeIdentifier=;SelfContained=false;_EFGenerationStage=$(_EFGenerationStage) + + <_EFInnerBuildProperties>Configuration=$(Configuration);Platform=$(Platform);PublishAot=false;_EFGenerationStage=$(_EFGenerationStage) + <_EFInnerBuildProperties Condition="'$(PublishAot)'=='true' Or '$(_EFPublishAOT)'=='true'">$(_EFInnerBuildProperties);RuntimeIdentifier=;SelfContained=false