Skip to content

Commit 71161b6

Browse files
committed
Merge branch 'releases/8.x.x'
2 parents dd41aa3 + 7d40a3d commit 71161b6

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Directory.Packages.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<ItemGroup>
33
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
4-
<PackageVersion Include="FluentAssertions" Version="6.12.2" />
4+
<PackageVersion Include="FluentAssertions" Version="7.0.0" />
55
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.2" />
66
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0" />
77
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.0" />
@@ -12,7 +12,7 @@
1212
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
1313
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.0" />
1414
<PackageVersion Include="Microsoft.Extensions.ObjectPool" Version="9.0.0" />
15-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
15+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
1616
<PackageVersion Include="Microsoft.SourceLink.AzureRepos.Git" Version="8.0.0" PrivateAssets="all" />
1717
<PackageVersion Include="NSubstitute" Version="5.3.0" />
1818
<PackageVersion Include="Serilog.Extensions.Logging" Version="8.0.0" />

src/Thinktecture.EntityFrameworkCore.Sqlite/EntityFrameworkCore/BulkOperations/SqliteBulkOperationExecutor.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,11 @@ private async Task<int> ExecuteBulkOperationAsync<T>(
196196

197197
try
198198
{
199+
// Execute bulk operations within a transaction, otherwise SQLite will start a new transaction for every statement
200+
await using var tx = _ctx.Database.CurrentTransaction == null
201+
? await _ctx.Database.BeginTransactionAsync(cancellationToken).ConfigureAwait(false)
202+
: null;
203+
199204
var tableIdentifier = _sqlGenerationHelper.DelimitIdentifier(tableName, schema);
200205

201206
using var reader = bulkOperationContext.CreateReader(entitiesOrValues);
@@ -207,6 +212,9 @@ private async Task<int> ExecuteBulkOperationAsync<T>(
207212
numberOfAffectedRows += await ExecuteBulkOperationForSeparatedOwnedEntitiesAsync((IReadOnlyList<object>)readEntities, bulkOperationContext, cancellationToken);
208213
}
209214

215+
if (tx is not null)
216+
await tx.CommitAsync(cancellationToken);
217+
210218
return numberOfAffectedRows;
211219
}
212220
finally

0 commit comments

Comments
 (0)