diff --git a/src/EFCore.Relational/Update/AffectedCountModificationCommandBatch.cs b/src/EFCore.Relational/Update/AffectedCountModificationCommandBatch.cs index 3bed70034d8..d994e8ad542 100644 --- a/src/EFCore.Relational/Update/AffectedCountModificationCommandBatch.cs +++ b/src/EFCore.Relational/Update/AffectedCountModificationCommandBatch.cs @@ -84,7 +84,7 @@ protected override void Consume(RelationalDataReader reader) "Expected " + expectedResultSetCount + " result sets, got " + actualResultSetCount); #endif } - catch (Exception ex) when (!(ex is DbUpdateException)) + catch (Exception ex) when (ex is not DbUpdateException and not OperationCanceledException) { throw new DbUpdateException( RelationalStrings.UpdateStoreException, @@ -150,7 +150,7 @@ protected override async Task ConsumeAsync( "Expected " + expectedResultSetCount + " result sets, got " + actualResultSetCount); #endif } - catch (Exception ex) when (!(ex is DbUpdateException)) + catch (Exception ex) when (ex is not DbUpdateException and not OperationCanceledException) { throw new DbUpdateException( RelationalStrings.UpdateStoreException, diff --git a/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs b/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs index e75c60907c5..ec416518130 100644 --- a/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs +++ b/src/EFCore.Relational/Update/ReaderModificationCommandBatch.cs @@ -252,11 +252,7 @@ public override void Execute(IRelationalConnection connection) Dependencies.Logger, CommandSource.SaveChanges)); Consume(dataReader); } - catch (DbUpdateException) - { - throw; - } - catch (Exception ex) + catch (Exception ex) when (ex is not DbUpdateException and not OperationCanceledException) { throw new DbUpdateException( RelationalStrings.UpdateStoreException, @@ -293,11 +289,7 @@ public override async Task ExecuteAsync( cancellationToken).ConfigureAwait(false); await ConsumeAsync(dataReader, cancellationToken).ConfigureAwait(false); } - catch (DbUpdateException) - { - throw; - } - catch (Exception ex) + catch (Exception ex) when (ex is not DbUpdateException and not OperationCanceledException) { throw new DbUpdateException( RelationalStrings.UpdateStoreException,