EF Core Issue - ExecuteUpdate with TagWith

CSharp · Console

/Program.cs

// @nuget: Microsoft.EntityFrameworkCore.SqlServer -Version 10.0.9

using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
	public static void Main()
	{
		using (var context = new EntityContext())
		{
			context.Database.EnsureCreated();
		}
		
		var customers = new List<Customer>();		

		using (var context = new EntityContext(true))
		{
			// TagWith work
			context.Customers.Where(x => x.CustomerID > 1).TagWith("TagWith will work").ExecuteUpdateAsync(x => x.SetProperty(y => y.Name, "Test"));
			
			Console.WriteLine("---");

			// TagWith doesn't work
			context.Customers.Where(x => x.CustomerID == 1).TagWith("TagWith will not work").ExecuteUpdateAsync(x => x.SetProperty(y => y.Name, "Test"));
		}	
	}
}

/EntityContext.cs

using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using System;

public class EntityContext : DbContext
{
	private readonly bool _enableLogging;
	
	public EntityContext(): this(false)
	{
	}
	
	public EntityContext(bool enableLogging) 
    {
        _enableLogging = enableLogging;
    }

	protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
	{
		optionsBuilder.UseSqlServer(new SqlConnection(FiddleHelper.GetConnectionStringSqlServer()));
		
		if (_enableLogging)
        {
            optionsBuilder.LogTo(Console.WriteLine, new[] { DbLoggerCategory.Database.Command.Name }, LogLevel.Information).EnableSensitiveDataLogging();
        }

		base.OnConfiguring(optionsBuilder);
	}

	public DbSet<Customer> Customers { get; set; }
}

public class Customer
{
	public int CustomerID { get; set; }
	public string Name { get; set; }
	public string Code { get; set; }
}
;