Skip to content

Code for precompiled query with .AsNoTracking() has variable name with dots in it #37972

Closed

Description

@donpanl

Bug description

Precompiling query with .AsNoTracking() generates code that has an incorrect variable name with dots included:

var extradots.BlogPrimaryKeyProperties = blogEntityType.FindPrimaryKey().Properties;

Compilation then fails with errors:

/workspaces/ef-play/extradots/Generated/Program.EFInterceptors.Context.cs(63,26): error CS1003: Syntax error, ',' expected
/workspaces/ef-play/extradots/Generated/Program.EFInterceptors.Context.cs(63,27): error CS1002: ; expected

Problem goes away if there is a .Select() in the query.

See attached project with minimal example.

Can be reproduced with:

> dotnet publish --ucr --sc

extradots.zip

Your code

--- Model.cs

namespace extradots;

public class Blog
{
    public int Id { get; set; }
}

--- Context.cs

using Microsoft.EntityFrameworkCore;

namespace extradots;

public class Context : DbContext
{
    public DbSet<Blog> Blogs { get; set; } = null!;

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        base.OnConfiguring(optionsBuilder);
        optionsBuilder.UseSqlite("Data Source=tmp.db");
    }
}

--- Program.cs

using Microsoft.EntityFrameworkCore;
using extradots;

using var context = new Context();

_ = context.Blogs
    .AsNoTracking()
    // .Select(b => b.Id)
    .ToList();

Stack traces


Verbose output


EF Core version

10.0.3, 11.0.0-preview.2.26159.112

Database provider

Microsoft.EntityFrameworkCore.Sqlite

Target framework

.NET 10, .NET 11

Operating system

Ubuntu 24.04.4 LTS

IDE

No response

Activity

  1. added theissue type on Mar 23, 2026
  2. added this to the Backlog milestone on Mar 23, 2026
  3. roji commented on Mar 23, 2026

    @roji
    Member

    Thanks for raising this. I'm putting on the backlog as we're looking at better ways to support NativeAOT, but at some point we'll do a push and I'll take a look at fixing this.

  4. added a commit that references this issue on Oct 9, 2026
    b62c52f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions