Starts in:
1 DAY
2 HRS
22 MIN
5 SEC
Starts in:
1 D
2 H
22 M
5 S

Activities of "Anawaz"

I increased the delay from 5000 to 15000 and now it is working. It seems Database was no ready before it runs dataseed. Updated code.

 private async Task MigrateAndSeedForTenantAsync(
     Guid tenantId,
     string adminEmail,
     string adminPassword)
 {
     try
     {
         using (_currentTenant.Change(tenantId))
         {
             await Task.Delay(15000);
             // Create database tables if needed
             using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
             {
                 var tenantConfiguration = await _tenantStore.FindAsync(tenantId);
                 if (tenantConfiguration?.ConnectionStrings != null &&
                     !tenantConfiguration.ConnectionStrings.Default.IsNullOrWhiteSpace())
                 {
                     foreach (var migrator in _dbSchemaMigrators)
                     {
                         await migrator.MigrateAsync();
                     }
                 }

                 await uow.CompleteAsync();
             }
             await Task.Delay(15000);
             // Seed data
             using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: true))
             {
                 await _dataSeeder.SeedAsync(
                     new DataSeedContext(tenantId)
                         .WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, adminEmail)
                         .WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, adminPassword)
                 );

                 await uow.CompleteAsync();
             }
         }
     }
     catch (Exception ex)
     {
         _logger.LogException(ex);
     }
 }
Showing 1 to 1 of 1 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06