From 92b3adf5a47ccfef2a3d73d9d6b4d6437bac9f8d Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 23 Feb 2024 17:44:47 +0800 Subject: [PATCH 1/5] Add `AbpUnitTestSqliteConnection` for unit test. Resolve #19065 --- .../Sqlite/AbpUnitTestSqliteConnection.cs | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Sqlite/AbpUnitTestSqliteConnection.cs diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Sqlite/AbpUnitTestSqliteConnection.cs b/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Sqlite/AbpUnitTestSqliteConnection.cs new file mode 100644 index 00000000000..f33f31ded33 --- /dev/null +++ b/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Sqlite/AbpUnitTestSqliteConnection.cs @@ -0,0 +1,52 @@ +using System.Threading; +using Microsoft.Data.Sqlite; +using Volo.Abp.Threading; + +namespace Volo.Abp.EntityFrameworkCore.Sqlite; + +/// +/// This class is for unit testing purposes. +/// It prevents exceptions in concurrent testing because Sqlite is not thread-safe. +/// +public class AbpUnitTestSqliteConnection : SqliteConnection +{ + public AbpUnitTestSqliteConnection(string connectionString) + : base(connectionString) + { + } + + public override SqliteCommand CreateCommand() + { + return new AbpSqliteCommand + { + Connection = this, + CommandTimeout = DefaultTimeout, + Transaction = Transaction + }; + } +} + +internal class AbpSqliteCommand : SqliteCommand +{ + private readonly static SemaphoreSlim SyncSemaphore = new SemaphoreSlim(1, 1); + + public override SqliteConnection? Connection + { + get => base.Connection; + set + { + using (SyncSemaphore.Lock()) + { + base.Connection = value; + } + } + } + + protected override void Dispose(bool disposing) + { + using (SyncSemaphore.Lock()) + { + base.Dispose(disposing); + } + } +} From 34d1ea3d9875a4011cbd57e77cd0dcad819f1c8a Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 23 Feb 2024 17:46:45 +0800 Subject: [PATCH 2/5] Update AbpUnitTestSqliteConnection.cs --- .../Sqlite/AbpUnitTestSqliteConnection.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Sqlite/AbpUnitTestSqliteConnection.cs b/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Sqlite/AbpUnitTestSqliteConnection.cs index f33f31ded33..e3b0dd7e304 100644 --- a/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Sqlite/AbpUnitTestSqliteConnection.cs +++ b/framework/src/Volo.Abp.EntityFrameworkCore.Sqlite/Volo/Abp/EntityFrameworkCore/Sqlite/AbpUnitTestSqliteConnection.cs @@ -28,14 +28,14 @@ public override SqliteCommand CreateCommand() internal class AbpSqliteCommand : SqliteCommand { - private readonly static SemaphoreSlim SyncSemaphore = new SemaphoreSlim(1, 1); + private readonly static SemaphoreSlim Semaphore = new SemaphoreSlim(1, 1); public override SqliteConnection? Connection { get => base.Connection; set { - using (SyncSemaphore.Lock()) + using (Semaphore.Lock()) { base.Connection = value; } @@ -44,7 +44,7 @@ public override SqliteConnection? Connection protected override void Dispose(bool disposing) { - using (SyncSemaphore.Lock()) + using (Semaphore.Lock()) { base.Dispose(disposing); } From 2c5ed8dd631d03f9b181709f48dd829a9d8eca54 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 23 Feb 2024 17:48:57 +0800 Subject: [PATCH 3/5] Use `AbpUnitTestSqliteConnection` instead of `SqliteConnection`. --- .../Volo/Abp/Auditing/AbpAuditingTestModule.cs | 2 +- .../Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs | 2 +- .../Volo/Abp/Account/AbpAccountApplicationTestModule.cs | 2 +- .../AbpAuditLoggingEntityFrameworkCoreTestModule.cs | 2 +- .../AbpBackgroundJobsEntityFrameworkCoreTestModule.cs | 2 +- .../BlobStoringDatabaseEntityFrameworkCoreTestModule.cs | 2 +- .../BloggingEntityFrameworkCoreTestModule.cs | 2 +- .../EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs | 2 +- .../EntityFrameworkCore/DocsEntityFrameworkCoreTestModule.cs | 2 +- .../AbpFeatureManagementEntityFrameworkCoreTestModule.cs | 2 +- .../AbpIdentityEntityFrameworkCoreTestModule.cs | 2 +- .../AbpIdentityServerTestEntityFrameworkCoreModule.cs | 2 +- .../OpenIddictEntityFrameworkCoreTestModule.cs | 2 +- .../AbpSettingManagementEntityFrameworkCoreTestModule.cs | 2 +- .../AbpTenantManagementEntityFrameworkCoreTestModule.cs | 2 +- .../MyProjectNameEntityFrameworkCoreTestModule.cs | 2 +- .../MyProjectNameEntityFrameworkCoreTestModule.cs | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/framework/test/Volo.Abp.Auditing.Tests/Volo/Abp/Auditing/AbpAuditingTestModule.cs b/framework/test/Volo.Abp.Auditing.Tests/Volo/Abp/Auditing/AbpAuditingTestModule.cs index 3a21cfaf5a8..c753d65d07c 100644 --- a/framework/test/Volo.Abp.Auditing.Tests/Volo/Abp/Auditing/AbpAuditingTestModule.cs +++ b/framework/test/Volo.Abp.Auditing.Tests/Volo/Abp/Auditing/AbpAuditingTestModule.cs @@ -62,7 +62,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); using (var context = new AbpAuditingTestDbContext(new DbContextOptionsBuilder() diff --git a/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs b/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs index f23ac14fda5..7db3130827d 100644 --- a/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs +++ b/framework/test/Volo.Abp.EntityFrameworkCore.Tests/Volo/Abp/EntityFrameworkCore/AbpEntityFrameworkCoreTestModule.cs @@ -93,7 +93,7 @@ await categoryRepository.InsertManyAsync(new List private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); using (var context = new TestMigrationsDbContext(new DbContextOptionsBuilder().UseSqlite(connection).Options)) diff --git a/modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AbpAccountApplicationTestModule.cs b/modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AbpAccountApplicationTestModule.cs index 100087f1fb4..2a6c9327531 100644 --- a/modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AbpAccountApplicationTestModule.cs +++ b/modules/account/test/Volo.Abp.Account.Application.Tests/Volo/Abp/Account/AbpAccountApplicationTestModule.cs @@ -44,7 +44,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) } private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new IdentityDbContext( diff --git a/modules/audit-logging/test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingEntityFrameworkCoreTestModule.cs b/modules/audit-logging/test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingEntityFrameworkCoreTestModule.cs index bb8570d253a..42d246625e3 100644 --- a/modules/audit-logging/test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingEntityFrameworkCoreTestModule.cs +++ b/modules/audit-logging/test/Volo.Abp.AuditLogging.EntityFrameworkCore.Tests/Volo/Abp/AuditLogging/EntityFrameworkCore/AbpAuditLoggingEntityFrameworkCoreTestModule.cs @@ -31,7 +31,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new AbpAuditLoggingDbContext( diff --git a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/AbpBackgroundJobsEntityFrameworkCoreTestModule.cs b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/AbpBackgroundJobsEntityFrameworkCoreTestModule.cs index a642ddc2276..c19016d0d0b 100644 --- a/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/AbpBackgroundJobsEntityFrameworkCoreTestModule.cs +++ b/modules/background-jobs/test/Volo.Abp.BackgroundJobs.EntityFrameworkCore.Tests/Volo/Abp/BackgroundJobs/EntityFrameworkCore/AbpBackgroundJobsEntityFrameworkCoreTestModule.cs @@ -31,7 +31,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new BackgroundJobsDbContext( diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs index 082b1640b75..6250a3f9d27 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs @@ -28,7 +28,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new BlobStoringDbContext( diff --git a/modules/blogging/test/Volo.Blogging.EntityFrameworkCore.Tests/Volo/Blogging/EntityFrameworkCore/BloggingEntityFrameworkCoreTestModule.cs b/modules/blogging/test/Volo.Blogging.EntityFrameworkCore.Tests/Volo/Blogging/EntityFrameworkCore/BloggingEntityFrameworkCoreTestModule.cs index 0a27448f6e9..498e8e7ab65 100644 --- a/modules/blogging/test/Volo.Blogging.EntityFrameworkCore.Tests/Volo/Blogging/EntityFrameworkCore/BloggingEntityFrameworkCoreTestModule.cs +++ b/modules/blogging/test/Volo.Blogging.EntityFrameworkCore.Tests/Volo/Blogging/EntityFrameworkCore/BloggingEntityFrameworkCoreTestModule.cs @@ -33,7 +33,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder().UseSqlite(connection).Options; diff --git a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs index 9b7fee252ac..139e4bdce9d 100644 --- a/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs +++ b/modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/CmsKitEntityFrameworkCoreTestModule.cs @@ -30,7 +30,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new CmsKitDbContext( diff --git a/modules/docs/test/Volo.Docs.EntityFrameworkCore.Tests/Volo/Docs/EntityFrameworkCore/DocsEntityFrameworkCoreTestModule.cs b/modules/docs/test/Volo.Docs.EntityFrameworkCore.Tests/Volo/Docs/EntityFrameworkCore/DocsEntityFrameworkCoreTestModule.cs index eb3a5ae5bde..fe3e32291ff 100644 --- a/modules/docs/test/Volo.Docs.EntityFrameworkCore.Tests/Volo/Docs/EntityFrameworkCore/DocsEntityFrameworkCoreTestModule.cs +++ b/modules/docs/test/Volo.Docs.EntityFrameworkCore.Tests/Volo/Docs/EntityFrameworkCore/DocsEntityFrameworkCoreTestModule.cs @@ -30,7 +30,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new DocsDbContext( diff --git a/modules/feature-management/test/Volo.Abp.FeatureManagement.EntityFrameworkCore.Tests/Volo/Abp/FeatureManagement/EntityFrameworkCore/AbpFeatureManagementEntityFrameworkCoreTestModule.cs b/modules/feature-management/test/Volo.Abp.FeatureManagement.EntityFrameworkCore.Tests/Volo/Abp/FeatureManagement/EntityFrameworkCore/AbpFeatureManagementEntityFrameworkCoreTestModule.cs index 3329f1dba64..242cf752332 100644 --- a/modules/feature-management/test/Volo.Abp.FeatureManagement.EntityFrameworkCore.Tests/Volo/Abp/FeatureManagement/EntityFrameworkCore/AbpFeatureManagementEntityFrameworkCoreTestModule.cs +++ b/modules/feature-management/test/Volo.Abp.FeatureManagement.EntityFrameworkCore.Tests/Volo/Abp/FeatureManagement/EntityFrameworkCore/AbpFeatureManagementEntityFrameworkCoreTestModule.cs @@ -36,7 +36,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new FeatureManagementDbContext( diff --git a/modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo/Abp/Identity/EntityFrameworkCore/AbpIdentityEntityFrameworkCoreTestModule.cs b/modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo/Abp/Identity/EntityFrameworkCore/AbpIdentityEntityFrameworkCoreTestModule.cs index beb2797ea9d..f0d1966bd0c 100644 --- a/modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo/Abp/Identity/EntityFrameworkCore/AbpIdentityEntityFrameworkCoreTestModule.cs +++ b/modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests/Volo/Abp/Identity/EntityFrameworkCore/AbpIdentityEntityFrameworkCoreTestModule.cs @@ -35,7 +35,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new IdentityDbContext( diff --git a/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs b/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs index 6e934d1d8c4..e6711fc1806 100644 --- a/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs +++ b/modules/identityserver/test/Volo.Abp.IdentityServer.EntityFrameworkCore.Tests/Volo/Abp/IdentityServer/AbpIdentityServerTestEntityFrameworkCoreModule.cs @@ -40,7 +40,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new IdentityDbContext( diff --git a/modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo/Abp/OpenIddict/EntityFrameworkCore/OpenIddictEntityFrameworkCoreTestModule.cs b/modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo/Abp/OpenIddict/EntityFrameworkCore/OpenIddictEntityFrameworkCoreTestModule.cs index b7bf2160981..c47ecc79962 100644 --- a/modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo/Abp/OpenIddict/EntityFrameworkCore/OpenIddictEntityFrameworkCoreTestModule.cs +++ b/modules/openiddict/test/Volo.Abp.OpenIddict.EntityFrameworkCore.Tests/Volo/Abp/OpenIddict/EntityFrameworkCore/OpenIddictEntityFrameworkCoreTestModule.cs @@ -37,7 +37,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new IdentityDbContext( diff --git a/modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo/Abp/SettingManagement/EntityFrameworkCore/AbpSettingManagementEntityFrameworkCoreTestModule.cs b/modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo/Abp/SettingManagement/EntityFrameworkCore/AbpSettingManagementEntityFrameworkCoreTestModule.cs index 9a2c51853e4..58df348af71 100644 --- a/modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo/Abp/SettingManagement/EntityFrameworkCore/AbpSettingManagementEntityFrameworkCoreTestModule.cs +++ b/modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests/Volo/Abp/SettingManagement/EntityFrameworkCore/AbpSettingManagementEntityFrameworkCoreTestModule.cs @@ -33,7 +33,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new SettingManagementDbContext( diff --git a/modules/tenant-management/test/Volo.Abp.TenantManagement.EntityFrameworkCore.Tests/Volo/Abp/TenantManagement/EntityFrameworkCore/AbpTenantManagementEntityFrameworkCoreTestModule.cs b/modules/tenant-management/test/Volo.Abp.TenantManagement.EntityFrameworkCore.Tests/Volo/Abp/TenantManagement/EntityFrameworkCore/AbpTenantManagementEntityFrameworkCoreTestModule.cs index 9358a422165..336fbb228fc 100644 --- a/modules/tenant-management/test/Volo.Abp.TenantManagement.EntityFrameworkCore.Tests/Volo/Abp/TenantManagement/EntityFrameworkCore/AbpTenantManagementEntityFrameworkCoreTestModule.cs +++ b/modules/tenant-management/test/Volo.Abp.TenantManagement.EntityFrameworkCore.Tests/Volo/Abp/TenantManagement/EntityFrameworkCore/AbpTenantManagementEntityFrameworkCoreTestModule.cs @@ -37,7 +37,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new TenantManagementDbContext( diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs index 1804d8cff79..b316391b5fe 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs @@ -59,7 +59,7 @@ public override void OnApplicationShutdown(ApplicationShutdownContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder() diff --git a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs index 7abdfb25f8e..aed68ef88c8 100644 --- a/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs +++ b/templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs @@ -33,7 +33,7 @@ public override void ConfigureServices(ServiceConfigurationContext context) private static SqliteConnection CreateDatabaseAndGetConnection() { - var connection = new SqliteConnection("Data Source=:memory:"); + var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:"); connection.Open(); new MyProjectNameDbContext( From f239163a9c845bf3473e8a954ed01a5836132f82 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 23 Feb 2024 19:06:09 +0800 Subject: [PATCH 4/5] Update BlobStoringDatabaseEntityFrameworkCoreTestModule.cs --- .../BlobStoringDatabaseEntityFrameworkCoreTestModule.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs index 6250a3f9d27..1f5bb843f02 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs @@ -2,6 +2,7 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage; +using Volo.Abp.EntityFrameworkCore.Sqlite; using Volo.Abp.EntityFrameworkCore; using Volo.Abp.Modularity; From c4cf58f673f1cb95614feceb77bfe931969bda83 Mon Sep 17 00:00:00 2001 From: maliming Date: Fri, 23 Feb 2024 21:03:35 +0800 Subject: [PATCH 5/5] Add `AbpEntityFrameworkCoreSqliteModule ` to `BlobStoringDatabaseEntityFrameworkCoreTestModule`. --- .../BlobStoringDatabaseEntityFrameworkCoreTestModule.cs | 3 ++- ...o.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs index 1f5bb843f02..038ca5874d5 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/EntityFrameworkCore/BlobStoringDatabaseEntityFrameworkCoreTestModule.cs @@ -10,7 +10,8 @@ namespace Volo.Abp.BlobStoring.Database.EntityFrameworkCore; [DependsOn( typeof(BlobStoringDatabaseTestBaseModule), - typeof(BlobStoringDatabaseEntityFrameworkCoreModule) + typeof(BlobStoringDatabaseEntityFrameworkCoreModule), + typeof(AbpEntityFrameworkCoreSqliteModule) )] public class BlobStoringDatabaseEntityFrameworkCoreTestModule : AbpModule { diff --git a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj index 59db9b77df2..b48e29993d2 100644 --- a/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj +++ b/modules/blob-storing-database/test/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests/Volo.Abp.BlobStoring.Database.EntityFrameworkCore.Tests.csproj @@ -11,6 +11,7 @@ +