Bug description
When a project is set to use NAOT, EF Core will always run in an AOT-compatible mode, meaning you have to compile models and queries for your application to be able to F5 debug (otherwise EF Core throws when creating the DbContext or doing a query), and query interceptors use system-specific paths so they can't be committed. I attempted to use the Microsoft.EntityFrameworkCore.Tasks package to get that working, but ran into my system getting all its RAM eaten instead. I narrowed it down to these two properies at once. This happens during build (which also means merely opening VS with this project will fork bomb the system as Intellisense initializes).
Your code
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EFOptimizeContext>true</EFOptimizeContext>
<EFScaffoldModelStage>build</EFScaffoldModelStage>
<EFPrecompileQueriesStage>build</EFPrecompileQueriesStage>
<PublishAot>true</PublishAot>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tasks" Version="10.0.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
using Microsoft.EntityFrameworkCore;
namespace sakilaConsole;
public partial class AppDbContext : DbContext
{
public AppDbContext()
{
}
public AppDbContext(DbContextOptions<AppDbContext> options)
: base(options)
{
}
public virtual DbSet<Entity> Entities { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseSqlite("Data Source=db.sqlite");
}
using System;
using System.Collections.Generic;
using System.Text;
namespace sakilaConsole;
public class Entity
{
public int Id { get; set; }
}
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
Stack traces
Verbose output
Build started at 5:55 PM...
<nothing else>
EF Core version
10.0.5
Database provider
Microsoft.EntityFrameworkCore.Sqlite
Target framework
.NET 10
Operating system
Windows 11
IDE
Visual Studio 2026
Bug description
When a project is set to use NAOT, EF Core will always run in an AOT-compatible mode, meaning you have to compile models and queries for your application to be able to F5 debug (otherwise EF Core throws when creating the DbContext or doing a query), and query interceptors use system-specific paths so they can't be committed. I attempted to use the
Microsoft.EntityFrameworkCore.Taskspackage to get that working, but ran into my system getting all its RAM eaten instead. I narrowed it down to these two properies at once. This happens during build (which also means merely opening VS with this project will fork bomb the system as Intellisense initializes).Your code
Stack traces
Verbose output
EF Core version
10.0.5
Database provider
Microsoft.EntityFrameworkCore.Sqlite
Target framework
.NET 10
Operating system
Windows 11
IDE
Visual Studio 2026