diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj
index 9bab4d252f..ec96f1ead6 100644
--- a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj
+++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityService.Host.csproj
@@ -29,6 +29,7 @@
+
diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs
index a9648a6748..7cc864b4bb 100644
--- a/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs
+++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/IdentityServiceHostModule.cs
@@ -7,7 +7,6 @@ using Microsoft.Extensions.DependencyInjection;
using StackExchange.Redis;
using Microsoft.OpenApi.Models;
using MsDemo.Shared;
-using Swashbuckle.AspNetCore.Swagger;
using Volo.Abp;
using Volo.Abp.AspNetCore.MultiTenancy;
using Volo.Abp.Auditing;
@@ -24,6 +23,7 @@ using Volo.Abp.MultiTenancy;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.Security.Claims;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
+using Volo.Abp.TenantManagement.EntityFrameworkCore;
namespace IdentityService.Host
{
@@ -37,7 +37,8 @@ namespace IdentityService.Host
typeof(AbpIdentityHttpApiModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpIdentityApplicationModule),
- typeof(AbpAspNetCoreMultiTenancyModule)
+ typeof(AbpAspNetCoreMultiTenancyModule),
+ typeof(AbpTenantManagementEntityFrameworkCoreModule)
)]
public class IdentityServiceHostModule : AbpModule
{
diff --git a/samples/MicroserviceDemo/microservices/IdentityService.Host/Tenants/TenantCreatedDistributedEventHandler.cs b/samples/MicroserviceDemo/microservices/IdentityService.Host/Tenants/TenantCreatedDistributedEventHandler.cs
new file mode 100644
index 0000000000..b006251902
--- /dev/null
+++ b/samples/MicroserviceDemo/microservices/IdentityService.Host/Tenants/TenantCreatedDistributedEventHandler.cs
@@ -0,0 +1,38 @@
+using System.Threading.Tasks;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Logging.Abstractions;
+using Volo.Abp.Data;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Domain.Entities.Events.Distributed;
+using Volo.Abp.EventBus.Distributed;
+using Volo.Abp.MultiTenancy;
+using Volo.Abp.TenantManagement;
+
+namespace IdentityService.Host.Tenants
+{
+ public class TenantCreatedDistributedEventHandler : IDistributedEventHandler>, ITransientDependency
+ {
+ public ILogger Logger { get; set; }
+ private readonly IDataSeeder _dataSeeder;
+ private readonly ICurrentTenant _currentTenant;
+
+ public TenantCreatedDistributedEventHandler(
+ IDataSeeder dataSeeder,
+ ICurrentTenant currentTenant)
+ {
+ _dataSeeder = dataSeeder;
+ _currentTenant = currentTenant;
+ Logger = NullLogger.Instance;
+ }
+
+ public async Task HandleEventAsync(EntityCreatedEto eventData)
+ {
+ Logger.LogInformation($"Handled distributed event for a new tenant creation. TenantId: {eventData.Entity.Id}");
+
+ using (_currentTenant.Change(eventData.Entity.Id, eventData.Entity.Name))
+ {
+ await _dataSeeder.SeedAsync(tenantId: eventData.Entity.Id);
+ }
+ }
+ }
+}