diff --git a/src/Fluss.Regen/Fluss.Regen.csproj b/src/Fluss.Regen/Fluss.Regen.csproj index 1464f7c..61adfa1 100644 --- a/src/Fluss.Regen/Fluss.Regen.csproj +++ b/src/Fluss.Regen/Fluss.Regen.csproj @@ -29,7 +29,7 @@ - + diff --git a/src/Fluss/Fluss.csproj b/src/Fluss/Fluss.csproj index fc920a9..c5398cf 100644 --- a/src/Fluss/Fluss.csproj +++ b/src/Fluss/Fluss.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/Fluss/UnitOfWork/UnitOfWorkFactory.cs b/src/Fluss/UnitOfWork/UnitOfWorkFactory.cs index aac3afe..35994c4 100644 --- a/src/Fluss/UnitOfWork/UnitOfWorkFactory.cs +++ b/src/Fluss/UnitOfWork/UnitOfWorkFactory.cs @@ -23,7 +23,8 @@ public async ValueTask Commit(Func action) await RetryPolicy .ExecuteAsync(async () => { - using var unitOfWork = serviceProvider.GetRequiredService(); + using var scope = serviceProvider.CreateScope(); + var unitOfWork = scope.ServiceProvider.GetRequiredService(); await action(unitOfWork); await unitOfWork.CommitInternal(); }); @@ -36,7 +37,8 @@ public async ValueTask Commit(Func> action) return await RetryPolicy .ExecuteAsync(async () => { - using var unitOfWork = serviceProvider.GetRequiredService(); + using var scope = serviceProvider.CreateScope(); + var unitOfWork = scope.ServiceProvider.GetRequiredService(); var result = await action(unitOfWork); await unitOfWork.CommitInternal(); return result;