Skip to content
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

AutoInclude causes ExecuteDelete to fail #30572

Closed
roji opened this issue Mar 24, 2023 · 0 comments · Fixed by #30571
Closed

AutoInclude causes ExecuteDelete to fail #30572

roji opened this issue Mar 24, 2023 · 0 comments · Fixed by #30571
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. Servicing-approved type-bug
Milestone

Comments

@roji
Copy link
Member

roji commented Mar 24, 2023

await using var ctx = new BlogContext();
await ctx.Database.EnsureDeletedAsync();
await ctx.Database.EnsureCreatedAsync();

ctx.Blogs
    .ExecuteDelete();

public class BlogContext : DbContext
{
    public DbSet<Blog> Blogs { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        => optionsBuilder
            .UseSqlServer(@"Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0;Encrypt=false")
            .LogTo(Console.WriteLine, LogLevel.Information)
            .EnableSensitiveDataLogging();

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Blog>(
            x => x.Navigation(b => b.Details).AutoInclude());
    }
}

public class Blog
{
    public int Id { get; set; }
    public string? Name { get; set; }

    public BlogDetails Details { get; set; }
}

public class BlogDetails
{
    public int Id { get; set; }
    public int Foo { get; set; }
}

Split off from #29992

@roji roji self-assigned this Mar 24, 2023
roji added a commit to roji/efcore that referenced this issue Mar 24, 2023
@roji roji added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Mar 24, 2023
roji added a commit that referenced this issue Mar 25, 2023
* Fully prune IncludeExpression before ExecuteUpdate, not just for the
  property lambda
* Prune also non-owned Includes

Fixes #30572
Fixes #30528
@roji roji added this to the 7.0.x milestone Mar 25, 2023
@roji roji reopened this Mar 25, 2023
roji added a commit to roji/efcore that referenced this issue Mar 25, 2023
* Fully prune IncludeExpression before ExecuteUpdate, not just for the
  property lambda
* Prune also non-owned Includes

Fixes dotnet#30572
Fixes dotnet#30528

(cherry picked from commit 4c6f854)
@ajcvickers ajcvickers modified the milestones: 7.0.x, 7.0.6 Mar 28, 2023
@ajcvickers ajcvickers modified the milestones: 7.0.6, 7.0.7 Jun 22, 2023
roji added a commit to roji/efcore that referenced this issue Nov 17, 2023
* Fully prune IncludeExpression before ExecuteUpdate, not just for the
  property lambda
* Prune also non-owned Includes

Fixes dotnet#30572
Fixes dotnet#30528

(cherry picked from commit 4c6f854)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. Servicing-approved type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants