From 893bf3ed9c5a84e9b6e667eb09fab08a4b430e4b Mon Sep 17 00:00:00 2001 From: Andriy Svyryd Date: Sat, 12 Oct 2024 21:06:15 -0700 Subject: [PATCH] Don't execute empty batches (#34882) Fixes #33337 --- .../Migrations/SqlServerMigrationsSqlGenerator.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs b/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs index f4192293658..90f980cf632 100644 --- a/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs +++ b/src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs @@ -1453,8 +1453,11 @@ protected override void Generate(SqlOperation operation, IModel? model, Migratio void AppendBatch(string batch) { - builder.Append(batch); - EndStatement(builder, operation.SuppressTransaction); + if (!string.IsNullOrWhiteSpace(batch)) + { + builder.Append(batch); + EndStatement(builder, operation.SuppressTransaction); + } } }