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.0.0-preview Updated on September 19, 2024, 10:13