From ec407ede0d03cf2430c3f12019d3b011d9917803 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Wed, 1 Dec 2021 17:44:53 +0300 Subject: [PATCH] Removed CatalogService EFCore and Added MongoDb project --- .../catalog/EShopOnAbp.CatalogService.sln | 28 ++++----- ....CatalogService.EntityFrameworkCore.csproj | 25 -------- .../CatalogServiceDbContext.cs | 34 ---------- .../CatalogServiceDbContextFactory.cs | 38 ------------ ...logServiceEfCoreEntityExtensionMappings.cs | 39 ------------ ...CatalogServiceEntityFrameworkCoreModule.cs | 37 ----------- .../20211125124215_Initial.Designer.cs | 30 --------- .../Migrations/20211125124215_Initial.cs | 19 ------ .../CatalogServiceDbContextModelSnapshot.cs | 28 --------- .../Properties/AssemblyInfo.cs | 2 - .../EShopOnAbp.CatalogService.MongoDB.csproj | 15 +++++ .../MongoDB/CatalogServiceMongoDbContext.cs | 20 ++++++ .../CatalogServiceMongoDbContextExtensions.cs | 14 +++++ .../MongoDB/CatalogServiceMongoDbModule.cs | 23 +++++++ .../MongoDB/ICatalogServiceMongoDbContext.cs | 13 ++++ ...ogService.EntityFrameworkCore.Tests.csproj | 20 ------ ...talogServiceEntityFrameworkCoreTestBase.cs | 9 --- ...logServiceEntityFrameworkCoreTestModule.cs | 62 ------------------- 18 files changed, 99 insertions(+), 357 deletions(-) delete mode 100644 services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EShopOnAbp.CatalogService.EntityFrameworkCore.csproj delete mode 100644 services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceDbContext.cs delete mode 100644 services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceDbContextFactory.cs delete mode 100644 services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceEfCoreEntityExtensionMappings.cs delete mode 100644 services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreModule.cs delete mode 100644 services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/20211125124215_Initial.Designer.cs delete mode 100644 services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/20211125124215_Initial.cs delete mode 100644 services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/CatalogServiceDbContextModelSnapshot.cs delete mode 100644 services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Properties/AssemblyInfo.cs create mode 100644 services/catalog/src/EShopOnAbp.CatalogService.MongoDB/EShopOnAbp.CatalogService.MongoDB.csproj create mode 100644 services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContext.cs create mode 100644 services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContextExtensions.cs create mode 100644 services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbModule.cs create mode 100644 services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/ICatalogServiceMongoDbContext.cs delete mode 100644 services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests.csproj delete mode 100644 services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreTestBase.cs delete mode 100644 services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreTestModule.cs diff --git a/services/catalog/EShopOnAbp.CatalogService.sln b/services/catalog/EShopOnAbp.CatalogService.sln index 42b4e1a5..90751a93 100644 --- a/services/catalog/EShopOnAbp.CatalogService.sln +++ b/services/catalog/EShopOnAbp.CatalogService.sln @@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.CatalogService.D EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.CatalogService.Application", "src\EShopOnAbp.CatalogService.Application\EShopOnAbp.CatalogService.Application.csproj", "{1A94A50E-06DC-43C1-80B5-B662820EC3EB}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.CatalogService.EntityFrameworkCore", "src\EShopOnAbp.CatalogService.EntityFrameworkCore\EShopOnAbp.CatalogService.EntityFrameworkCore.csproj", "{C956DD76-69C8-4A9C-83EA-D17DF83340FD}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{CA9AC87F-097E-4F15-8393-4BC07735A5B0}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{04DBDB01-70F4-4E06-B468-8F87850B22BE}" @@ -23,8 +21,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.CatalogService.H EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.CatalogService.HttpApi.Client", "src\EShopOnAbp.CatalogService.HttpApi.Client\EShopOnAbp.CatalogService.HttpApi.Client.csproj", "{3B5A0094-670D-4BB1-BFDD-61B88A8773DC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.CatalogService.EntityFrameworkCore.Tests", "test\EShopOnAbp.CatalogService.EntityFrameworkCore.Tests\EShopOnAbp.CatalogService.EntityFrameworkCore.Tests.csproj", "{1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.CatalogService.TestBase", "test\EShopOnAbp.CatalogService.TestBase\EShopOnAbp.CatalogService.TestBase.csproj", "{91853F21-9CD9-4132-BC29-A7D5D84FFFE7}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.CatalogService.Domain.Tests", "test\EShopOnAbp.CatalogService.Domain.Tests\EShopOnAbp.CatalogService.Domain.Tests.csproj", "{E512F4D9-9375-480F-A2F6-A46509F9D824}" @@ -33,6 +29,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.CatalogService.H EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.CatalogService.HttpApi.Host", "src\EShopOnAbp.CatalogService.HttpApi.Host\EShopOnAbp.CatalogService.HttpApi.Host.csproj", "{748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EShopOnAbp.CatalogService.MongoDB", "src\EShopOnAbp.CatalogService.MongoDB\EShopOnAbp.CatalogService.MongoDB.csproj", "{5D15000F-E6C4-45ED-96BC-6B6A029BA584}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EShopOnAbp.CatalogService.MongoDB.Tests", "test\EShopOnAbp.CatalogService.MongoDB.Tests\EShopOnAbp.CatalogService.MongoDB.Tests.csproj", "{353E567B-0519-4768-92DD-DC88E318E5B6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -47,10 +47,6 @@ Global {1A94A50E-06DC-43C1-80B5-B662820EC3EB}.Debug|Any CPU.Build.0 = Debug|Any CPU {1A94A50E-06DC-43C1-80B5-B662820EC3EB}.Release|Any CPU.ActiveCfg = Release|Any CPU {1A94A50E-06DC-43C1-80B5-B662820EC3EB}.Release|Any CPU.Build.0 = Release|Any CPU - {C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C956DD76-69C8-4A9C-83EA-D17DF83340FD}.Release|Any CPU.Build.0 = Release|Any CPU {50B2631D-129C-47B3-A587-029CCD6099BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {50B2631D-129C-47B3-A587-029CCD6099BC}.Debug|Any CPU.Build.0 = Debug|Any CPU {50B2631D-129C-47B3-A587-029CCD6099BC}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -71,10 +67,6 @@ Global {3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Debug|Any CPU.Build.0 = Debug|Any CPU {3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Release|Any CPU.ActiveCfg = Release|Any CPU {3B5A0094-670D-4BB1-BFDD-61B88A8773DC}.Release|Any CPU.Build.0 = Release|Any CPU - {1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81}.Release|Any CPU.Build.0 = Release|Any CPU {91853F21-9CD9-4132-BC29-A7D5D84FFFE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {91853F21-9CD9-4132-BC29-A7D5D84FFFE7}.Debug|Any CPU.Build.0 = Debug|Any CPU {91853F21-9CD9-4132-BC29-A7D5D84FFFE7}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -91,6 +83,14 @@ Global {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Debug|Any CPU.Build.0 = Debug|Any CPU {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Release|Any CPU.ActiveCfg = Release|Any CPU {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Release|Any CPU.Build.0 = Release|Any CPU + {5D15000F-E6C4-45ED-96BC-6B6A029BA584}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5D15000F-E6C4-45ED-96BC-6B6A029BA584}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5D15000F-E6C4-45ED-96BC-6B6A029BA584}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5D15000F-E6C4-45ED-96BC-6B6A029BA584}.Release|Any CPU.Build.0 = Release|Any CPU + {353E567B-0519-4768-92DD-DC88E318E5B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {353E567B-0519-4768-92DD-DC88E318E5B6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {353E567B-0519-4768-92DD-DC88E318E5B6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {353E567B-0519-4768-92DD-DC88E318E5B6}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -98,17 +98,17 @@ Global GlobalSection(NestedProjects) = preSolution {554AD327-6DBA-4F8F-96F8-81CE7A0C863F} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {1A94A50E-06DC-43C1-80B5-B662820EC3EB} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} - {C956DD76-69C8-4A9C-83EA-D17DF83340FD} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {50B2631D-129C-47B3-A587-029CCD6099BC} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {42F719ED-8413-4895-B5B4-5AB56079BC66} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {520659C8-C734-4298-A3DA-B539DB9DFC0B} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {4164BDF7-F527-4E85-9CE6-E3C2D7426A27} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} {3B5A0094-670D-4BB1-BFDD-61B88A8773DC} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} - {1FE30EB9-74A9-47F5-A9F6-7B1FAB672D81} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {91853F21-9CD9-4132-BC29-A7D5D84FFFE7} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {E512F4D9-9375-480F-A2F6-A46509F9D824} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {EF480016-9127-4916-8735-D2466BDBC582} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} + {5D15000F-E6C4-45ED-96BC-6B6A029BA584} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} + {353E567B-0519-4768-92DD-DC88E318E5B6} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6AAFA1C6-603E-13FA-45E5-7910AA9F661D} diff --git a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EShopOnAbp.CatalogService.EntityFrameworkCore.csproj b/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EShopOnAbp.CatalogService.EntityFrameworkCore.csproj deleted file mode 100644 index f5fa1c4c..00000000 --- a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EShopOnAbp.CatalogService.EntityFrameworkCore.csproj +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - net6.0 - EShopOnAbp.CatalogService - - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers - compile; contentFiles; build; buildMultitargeting; buildTransitive; analyzers; native - - - - diff --git a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceDbContext.cs b/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceDbContext.cs deleted file mode 100644 index d0a3d751..00000000 --- a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceDbContext.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Data; -using Volo.Abp.EntityFrameworkCore; - -namespace EShopOnAbp.CatalogService.EntityFrameworkCore -{ - [ConnectionStringName(CatalogServiceDbProperties.ConnectionStringName)] - public class CatalogServiceDbContext : - AbpDbContext - { - /* Add DbSet properties for your Aggregate Roots / Entities here. */ - - public CatalogServiceDbContext(DbContextOptions options) - : base(options) - { - } - - protected override void OnModelCreating(ModelBuilder builder) - { - base.OnModelCreating(builder); - - /* Include modules to your migration db context */ - - /* Configure your own tables/entities inside here */ - - //builder.Entity(b => - //{ - // b.ToTable(CatalogServiceConsts.DbTablePrefix + "YourEntities", CatalogServiceConsts.DbSchema); - // b.ConfigureByConvention(); //auto configure for the base class props - // //... - //}); - } - } -} diff --git a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceDbContextFactory.cs b/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceDbContextFactory.cs deleted file mode 100644 index 55b44780..00000000 --- a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceDbContextFactory.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System.IO; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Design; -using Microsoft.Extensions.Configuration; - -namespace EShopOnAbp.CatalogService.EntityFrameworkCore -{ - /* This class is needed for EF Core console commands - * (like Add-Migration and Update-Database commands) */ - public class CatalogServiceDbContextFactory : IDesignTimeDbContextFactory - { - public CatalogServiceDbContext CreateDbContext(string[] args) - { - CatalogServiceEfCoreEntityExtensionMappings.Configure(); - - var configuration = BuildConfiguration(); - - var builder = new DbContextOptionsBuilder() - .UseNpgsql( - configuration.GetConnectionString(CatalogServiceDbProperties.ConnectionStringName), - b => - { - b.MigrationsHistoryTable("__CatalogService_Migrations"); - }); - - return new CatalogServiceDbContext(builder.Options); - } - - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../EShopOnAbp.CatalogService.HttpApi.Host")) - .AddJsonFile("appsettings.json", optional: false); - - return builder.Build(); - } - } -} diff --git a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceEfCoreEntityExtensionMappings.cs b/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceEfCoreEntityExtensionMappings.cs deleted file mode 100644 index 853e339f..00000000 --- a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceEfCoreEntityExtensionMappings.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Volo.Abp.Threading; - -namespace EShopOnAbp.CatalogService.EntityFrameworkCore -{ - public static class CatalogServiceEfCoreEntityExtensionMappings - { - private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); - - public static void Configure() - { - OneTimeRunner.Run(() => - { - /* You can configure extra properties for the - * entities defined in the modules used by your application. - * - * This class can be used to map these extra properties to table fields in the database. - * - * USE THIS CLASS ONLY TO CONFIGURE EF CORE RELATED MAPPING. - * USE CatalogServiceModuleExtensionConfigurator CLASS (in the Domain.Shared project) - * FOR A HIGH LEVEL API TO DEFINE EXTRA PROPERTIES TO ENTITIES OF THE USED MODULES - * - * Example: Map a property to a table field: - - ObjectExtensionManager.Instance - .MapEfCoreProperty( - "MyProperty", - (entityBuilder, propertyBuilder) => - { - propertyBuilder.HasMaxLength(128); - } - ); - - * See the documentation for more: - * https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities - */ - }); - } - } -} diff --git a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreModule.cs b/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreModule.cs deleted file mode 100644 index 62d8e651..00000000 --- a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreModule.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore.PostgreSql; -using Volo.Abp.Modularity; - -namespace EShopOnAbp.CatalogService.EntityFrameworkCore -{ - [DependsOn( - typeof(CatalogServiceDomainModule), - typeof(AbpEntityFrameworkCorePostgreSqlModule) - )] - public class CatalogServiceEntityFrameworkCoreModule : AbpModule - { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - CatalogServiceEfCoreEntityExtensionMappings.Configure(); - } - - public override void ConfigureServices(ServiceConfigurationContext context) - { - context.Services.AddAbpDbContext(options => - { - /* Remove "includeAllEntities: true" to create - * default repositories only for aggregate roots */ - options.AddDefaultRepositories(includeAllEntities: true); - }); - - Configure(options => - { - options.UseNpgsql(b => - { - b.MigrationsHistoryTable("__CatalogService_Migrations"); - }); - }); - } - } -} diff --git a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/20211125124215_Initial.Designer.cs b/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/20211125124215_Initial.Designer.cs deleted file mode 100644 index 05f04edc..00000000 --- a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/20211125124215_Initial.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -// -using EShopOnAbp.CatalogService.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Volo.Abp.EntityFrameworkCore; - -#nullable disable - -namespace EShopOnAbp.CatalogService.Migrations -{ - [DbContext(typeof(CatalogServiceDbContext))] - [Migration("20211125124215_Initial")] - partial class Initial - { - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.PostgreSql) - .HasAnnotation("ProductVersion", "6.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); -#pragma warning restore 612, 618 - } - } -} diff --git a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/20211125124215_Initial.cs b/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/20211125124215_Initial.cs deleted file mode 100644 index aac30a21..00000000 --- a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/20211125124215_Initial.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace EShopOnAbp.CatalogService.Migrations -{ - public partial class Initial : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/CatalogServiceDbContextModelSnapshot.cs b/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/CatalogServiceDbContextModelSnapshot.cs deleted file mode 100644 index 6b110a46..00000000 --- a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/CatalogServiceDbContextModelSnapshot.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -using EShopOnAbp.CatalogService.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Volo.Abp.EntityFrameworkCore; - -#nullable disable - -namespace EShopOnAbp.CatalogService.Migrations -{ - [DbContext(typeof(CatalogServiceDbContext))] - partial class CatalogServiceDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.PostgreSql) - .HasAnnotation("ProductVersion", "6.0.0") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); -#pragma warning restore 612, 618 - } - } -} diff --git a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Properties/AssemblyInfo.cs b/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Properties/AssemblyInfo.cs deleted file mode 100644 index 86e7b2d0..00000000 --- a/services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,2 +0,0 @@ -using System.Runtime.CompilerServices; -[assembly:InternalsVisibleToAttribute("EShopOnAbp.CatalogService.EntityFrameworkCore.Tests")] diff --git a/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/EShopOnAbp.CatalogService.MongoDB.csproj b/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/EShopOnAbp.CatalogService.MongoDB.csproj new file mode 100644 index 00000000..071a43af --- /dev/null +++ b/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/EShopOnAbp.CatalogService.MongoDB.csproj @@ -0,0 +1,15 @@ + + + + + + net6.0 + EShopOnAbp.CatalogService + + + + + + + + diff --git a/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContext.cs b/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContext.cs new file mode 100644 index 00000000..1174501a --- /dev/null +++ b/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContext.cs @@ -0,0 +1,20 @@ +using Volo.Abp.Data; +using Volo.Abp.MongoDB; + +namespace EShopOnAbp.CatalogService.MongoDB +{ + [ConnectionStringName(CatalogServiceDbProperties.ConnectionStringName)] + public class CatalogServiceMongoDbContext : AbpMongoDbContext, ICatalogServiceMongoDbContext + { + /* Add mongo collections here. Example: + * public IMongoCollection Questions => Collection(); + */ + + protected override void CreateModel(IMongoModelBuilder modelBuilder) + { + base.CreateModel(modelBuilder); + + modelBuilder.ConfigureCatalogService(); + } + } +} \ No newline at end of file diff --git a/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContextExtensions.cs b/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContextExtensions.cs new file mode 100644 index 00000000..5dca0500 --- /dev/null +++ b/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContextExtensions.cs @@ -0,0 +1,14 @@ +using Volo.Abp; +using Volo.Abp.MongoDB; + +namespace EShopOnAbp.CatalogService.MongoDB +{ + public static class CatalogServiceMongoDbContextExtensions + { + public static void ConfigureCatalogService( + this IMongoModelBuilder builder) + { + Check.NotNull(builder, nameof(builder)); + } + } +} diff --git a/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbModule.cs b/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbModule.cs new file mode 100644 index 00000000..b5d08c13 --- /dev/null +++ b/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbModule.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; +using Volo.Abp.MongoDB; + +namespace EShopOnAbp.CatalogService.MongoDB +{ + [DependsOn( + typeof(CatalogServiceDomainModule), + typeof(AbpMongoDbModule) + )] + public class CatalogServiceMongoDbModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddMongoDbContext(options => + { + /* Add custom repositories here. Example: + * options.AddRepository(); + */ + }); + } + } +} diff --git a/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/ICatalogServiceMongoDbContext.cs b/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/ICatalogServiceMongoDbContext.cs new file mode 100644 index 00000000..8dab1e0a --- /dev/null +++ b/services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/ICatalogServiceMongoDbContext.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Data; +using Volo.Abp.MongoDB; + +namespace EShopOnAbp.CatalogService.MongoDB +{ + [ConnectionStringName(CatalogServiceDbProperties.ConnectionStringName)] + public interface ICatalogServiceMongoDbContext : IAbpMongoDbContext + { + /* Define mongo collections here. Example: + * IMongoCollection Questions { get; } + */ + } +} diff --git a/services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests.csproj b/services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests.csproj deleted file mode 100644 index 35e7b5b0..00000000 --- a/services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - net6.0 - EShopOnAbp.CatalogService - - - - - - - - - - - - - diff --git a/services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreTestBase.cs b/services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreTestBase.cs deleted file mode 100644 index 9b8ca18b..00000000 --- a/services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreTestBase.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Volo.Abp; - -namespace EShopOnAbp.CatalogService.EntityFrameworkCore -{ - public abstract class CatalogServiceEntityFrameworkCoreTestBase : CatalogServiceTestBase - { - - } -} diff --git a/services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreTestModule.cs b/services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreTestModule.cs deleted file mode 100644 index e1be3bb1..00000000 --- a/services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreTestModule.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Microsoft.Data.Sqlite; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp; -using Volo.Abp.EntityFrameworkCore; -using Volo.Abp.EntityFrameworkCore.Sqlite; -using Volo.Abp.Modularity; - -namespace EShopOnAbp.CatalogService.EntityFrameworkCore -{ - [DependsOn( - typeof(CatalogServiceEntityFrameworkCoreModule), - typeof(CatalogServiceTestBaseModule), - typeof(AbpEntityFrameworkCoreSqliteModule) - )] - public class CatalogServiceEntityFrameworkCoreTestModule : AbpModule - { - private SqliteConnection _sqliteConnection; - - public override void ConfigureServices(ServiceConfigurationContext context) - { - ConfigureInMemorySqlite(context.Services); - } - - private void ConfigureInMemorySqlite(IServiceCollection services) - { - _sqliteConnection = CreateDatabaseAndGetConnection(); - - services.Configure(options => - { - options.Configure(context => - { - context.DbContextOptions.UseSqlite(_sqliteConnection); - }); - }); - } - - public override void OnApplicationShutdown(ApplicationShutdownContext context) - { - _sqliteConnection.Dispose(); - } - - private static SqliteConnection CreateDatabaseAndGetConnection() - { - var connection = new SqliteConnection("Data Source=:memory:"); - connection.Open(); - - var options = new DbContextOptionsBuilder() - .UseSqlite(connection) - .Options; - - using (var context = new CatalogServiceDbContext(options)) - { - context.GetService().CreateTables(); - } - - return connection; - } - } -}