Browse Source
Merge pull request #15508 from abpframework/AutoTransactionBehavior
Set `AutoTransactionBehavior ` to `Never` when always disabling transactions.
pull/15513/head
liangshiwei
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
10 additions and
0 deletions
-
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
-
templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs
-
templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs
|
|
|
@ -227,6 +227,11 @@ public abstract class AbpDbContext<TDbContext> : DbContext, IAbpEfCoreDbContext, |
|
|
|
|
|
|
|
ChangeTracker.Tracked += ChangeTracker_Tracked; |
|
|
|
ChangeTracker.StateChanged += ChangeTracker_StateChanged; |
|
|
|
|
|
|
|
if (UnitOfWorkManager is AlwaysDisableTransactionsUnitOfWorkManager) |
|
|
|
{ |
|
|
|
Database.AutoTransactionBehavior = AutoTransactionBehavior.Never; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual void ChangeTracker_Tracked(object sender, EntityTrackedEventArgs e) |
|
|
|
|
|
|
|
@ -7,6 +7,7 @@ using Volo.Abp; |
|
|
|
using Volo.Abp.EntityFrameworkCore; |
|
|
|
using Volo.Abp.EntityFrameworkCore.Sqlite; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
|
|
|
|
namespace MyCompanyName.MyProjectName.EntityFrameworkCore; |
|
|
|
|
|
|
|
@ -21,6 +22,7 @@ public class MyProjectNameEntityFrameworkCoreTestModule : AbpModule |
|
|
|
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
context.Services.AddAlwaysDisableUnitOfWorkTransaction(); |
|
|
|
ConfigureInMemorySqlite(context.Services); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore.Storage; |
|
|
|
using Volo.Abp.EntityFrameworkCore; |
|
|
|
using Volo.Abp.EntityFrameworkCore.Sqlite; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
|
|
|
|
namespace MyCompanyName.MyProjectName.EntityFrameworkCore; |
|
|
|
|
|
|
|
@ -17,6 +18,8 @@ public class MyProjectNameEntityFrameworkCoreTestModule : AbpModule |
|
|
|
{ |
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context) |
|
|
|
{ |
|
|
|
context.Services.AddAlwaysDisableUnitOfWorkTransaction(); |
|
|
|
|
|
|
|
var sqliteConnection = CreateDatabaseAndGetConnection(); |
|
|
|
|
|
|
|
Configure<AbpDbContextOptions>(options => |
|
|
|
|