Browse Source

Removed CatalogService EFCore and Added MongoDb project

pull/32/head
Galip Tolga Erdem 5 years ago
parent
commit
ec407ede0d
  1. 28
      services/catalog/EShopOnAbp.CatalogService.sln
  2. 25
      services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EShopOnAbp.CatalogService.EntityFrameworkCore.csproj
  3. 34
      services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceDbContext.cs
  4. 38
      services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceDbContextFactory.cs
  5. 39
      services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceEfCoreEntityExtensionMappings.cs
  6. 37
      services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreModule.cs
  7. 30
      services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/20211125124215_Initial.Designer.cs
  8. 19
      services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/20211125124215_Initial.cs
  9. 28
      services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/CatalogServiceDbContextModelSnapshot.cs
  10. 2
      services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Properties/AssemblyInfo.cs
  11. 15
      services/catalog/src/EShopOnAbp.CatalogService.MongoDB/EShopOnAbp.CatalogService.MongoDB.csproj
  12. 20
      services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContext.cs
  13. 14
      services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContextExtensions.cs
  14. 23
      services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbModule.cs
  15. 13
      services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/ICatalogServiceMongoDbContext.cs
  16. 20
      services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests.csproj
  17. 9
      services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreTestBase.cs
  18. 62
      services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreTestModule.cs

28
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}

25
services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EShopOnAbp.CatalogService.EntityFrameworkCore.csproj

@ -1,25 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>EShopOnAbp.CatalogService</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\EShopOnAbp.CatalogService.Domain\EShopOnAbp.CatalogService.Domain.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" Version="5.0.0-rc.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>compile; contentFiles; build; buildMultitargeting; buildTransitive; analyzers; native</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

34
services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceDbContext.cs

@ -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<CatalogServiceDbContext>
{
/* Add DbSet properties for your Aggregate Roots / Entities here. */
public CatalogServiceDbContext(DbContextOptions<CatalogServiceDbContext> 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<YourEntity>(b =>
//{
// b.ToTable(CatalogServiceConsts.DbTablePrefix + "YourEntities", CatalogServiceConsts.DbSchema);
// b.ConfigureByConvention(); //auto configure for the base class props
// //...
//});
}
}
}

38
services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceDbContextFactory.cs

@ -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<CatalogServiceDbContext>
{
public CatalogServiceDbContext CreateDbContext(string[] args)
{
CatalogServiceEfCoreEntityExtensionMappings.Configure();
var configuration = BuildConfiguration();
var builder = new DbContextOptionsBuilder<CatalogServiceDbContext>()
.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();
}
}
}

39
services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceEfCoreEntityExtensionMappings.cs

@ -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<IdentityUser, string>(
"MyProperty",
(entityBuilder, propertyBuilder) =>
{
propertyBuilder.HasMaxLength(128);
}
);
* See the documentation for more:
* https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities
*/
});
}
}
}

37
services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreModule.cs

@ -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<CatalogServiceDbContext>(options =>
{
/* Remove "includeAllEntities: true" to create
* default repositories only for aggregate roots */
options.AddDefaultRepositories(includeAllEntities: true);
});
Configure<AbpDbContextOptions>(options =>
{
options.UseNpgsql(b =>
{
b.MigrationsHistoryTable("__CatalogService_Migrations");
});
});
}
}
}

30
services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/20211125124215_Initial.Designer.cs

@ -1,30 +0,0 @@
// <auto-generated />
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
}
}
}

19
services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/20211125124215_Initial.cs

@ -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)
{
}
}
}

28
services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Migrations/CatalogServiceDbContextModelSnapshot.cs

@ -1,28 +0,0 @@
// <auto-generated />
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
}
}
}

2
services/catalog/src/EShopOnAbp.CatalogService.EntityFrameworkCore/Properties/AssemblyInfo.cs

@ -1,2 +0,0 @@
using System.Runtime.CompilerServices;
[assembly:InternalsVisibleToAttribute("EShopOnAbp.CatalogService.EntityFrameworkCore.Tests")]

15
services/catalog/src/EShopOnAbp.CatalogService.MongoDB/EShopOnAbp.CatalogService.MongoDB.csproj

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>EShopOnAbp.CatalogService</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.MongoDB" Version="5.0.0-rc.1" />
<ProjectReference Include="..\EShopOnAbp.CatalogService.Domain\EShopOnAbp.CatalogService.Domain.csproj" />
</ItemGroup>
</Project>

20
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<Question> Questions => Collection<Question>();
*/
protected override void CreateModel(IMongoModelBuilder modelBuilder)
{
base.CreateModel(modelBuilder);
modelBuilder.ConfigureCatalogService();
}
}
}

14
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));
}
}
}

23
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<CatalogServiceMongoDbContext>(options =>
{
/* Add custom repositories here. Example:
* options.AddRepository<Question, MongoQuestionRepository>();
*/
});
}
}
}

13
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<Question> Questions { get; }
*/
}
}

20
services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests.csproj

@ -1,20 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>EShopOnAbp.CatalogService</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\EShopOnAbp.CatalogService.EntityFrameworkCore\EShopOnAbp.CatalogService.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\EShopOnAbp.CatalogService.TestBase\EShopOnAbp.CatalogService.TestBase.csproj" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.Sqlite" Version="5.0.0-rc.1" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
</ItemGroup>
</Project>

9
services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreTestBase.cs

@ -1,9 +0,0 @@
using Volo.Abp;
namespace EShopOnAbp.CatalogService.EntityFrameworkCore
{
public abstract class CatalogServiceEntityFrameworkCoreTestBase : CatalogServiceTestBase<CatalogServiceEntityFrameworkCoreTestModule>
{
}
}

62
services/catalog/test/EShopOnAbp.CatalogService.EntityFrameworkCore.Tests/EntityFrameworkCore/CatalogServiceEntityFrameworkCoreTestModule.cs

@ -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<AbpDbContextOptions>(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<CatalogServiceDbContext>()
.UseSqlite(connection)
.Options;
using (var context = new CatalogServiceDbContext(options))
{
context.GetService<IRelationalDatabaseCreator>().CreateTables();
}
return connection;
}
}
}
Loading…
Cancel
Save