private async Task MigrateHostDatabaseAsync() { Logger.LogInformation("Migrating host database schema..."); await _dbSchemaMigrator.MigrateAsync(); Logger.LogInformation("Executing host database seed..."); await _dataSeeder.SeedAsync(); Logger.LogInformation("Successfully completed host database migrations."); }
public async Task FooAsync() { // 内部调用所有IDataSeedContributor实现以完成数据播种 // 可以在这里设置租户 await _dataSeeder.SeedAsync(new Guid()); // 将命名的配置参数发送到SeedAsync方法 await _dataSeeder.SeedAsync( new DataSeedContext() .WithProperty("MyProperty1", "MyValue1") .WithProperty("MyProperty2", 42) ); }
public async Task BuildInternalAsync() { await _dataSeeder.SeedAsync(); await _bookRepository.InsertAsync( new Book { Id = Guid.NewGuid(), Name = "Test book 1", Type = BookType.Fantastic, PublishDate = new DateTime(2015, 05, 24), Price = 21 } ); await _bookRepository.InsertAsync( new Book { Id = Guid.NewGuid(), Name = "Test book 2", Type = BookType.Science, PublishDate = new DateTime(2014, 02, 11), Price = 15 } ); }
private async Task SeedDataAsync(Tenant tenant = null) { Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); await _dataSeeder.SeedAsync(new DataSeedContext(tenant?.Id) .WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, IdentityDataSeedContributor.AdminEmailDefaultValue) .WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, IdentityDataSeedContributor.AdminPasswordDefaultValue) ); }
private Task SeedHostDataAsync() { _logger.LogInformation($"Executing database seed..."); return(_dataSeeder.SeedAsync(new DataSeedContext() .WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, IdentityDataSeedContributor.AdminEmailDefaultValue) .WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, IdentityDataSeedContributor.AdminPasswordDefaultValue) )); }
public async Task HandleEventAsync(EntityCreatedEto <TenantEto> 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); } }
public async Task MigrateAsync() { foreach (var migrator in _dbSchemaMigrators) { await migrator.MigrateAsync(); } await _dataSeeder.SeedAsync(); }
private async Task SeedDataAsync(Tenant? tenant = null) { Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); var adminEmail = _configuration["Admin:Email"] ?? "*****@*****.**"; var adminPassword = _configuration["Admin:Password"] ?? "1q2w3E*"; var context = new DataSeedContext(tenant?.Id) .WithProperty("AdminEmail", adminEmail) .WithProperty("AdminPassword", adminPassword); await _dataSeeder.SeedAsync(context); }
public async Task MigrateAsync() { Logger.LogInformation($"Started {AbpIdentityDbProperties.ConnectionStringName} database migrations..."); Logger.LogInformation("Migrating database schema..."); await _dbSchemaMigrator.MigrateAsync(); Logger.LogInformation("Executing database seed..."); await _dataSeeder.SeedAsync(); Logger.LogInformation("Successfully completed database migrations."); }
public async Task MigrateAsync() { Logger.LogInformation("Started database migrations..."); Logger.LogInformation("Migrating database schema..."); await _dbSchemaMigrator.MigrateAsync(); Logger.LogInformation("Executing database seed..."); await _dataSeeder.SeedAsync(); Logger.LogInformation("Successfully completed database migrations."); }
public async Task MigrateAsync() { // Logger.LogInformation("Started database migrations..."); foreach (var migrator in _dbSchemaMigrators) { await migrator.MigrateAsync(); } await _dataSeeder.SeedAsync(); // Logger.LogInformation("Started database migrations..."); }
private async Task SeedDataAsync(Tenant tenant = null) { Logger.LogInformation($"Migrating schema for {tenant?.Name} database..."); foreach (var migrator in _dbSchemaMigrators) { await migrator.MigrateAsync(); } Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); await _dataSeeder.SeedAsync(tenant?.Id); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime lifetime, IDataSeeder dataSeeder) { if (env.IsDevelopment() || env.IsEnvironment("local")) { app.UseDeveloperExceptionPage(); } app.UseErrorHandler(); app.UseMvc(); lifetime.ApplicationStopped.Register(() => Container.Dispose()); dataSeeder.SeedAsync().Wait(); }
private async Task MigrateAndSeedForTenantAsync( Guid tenantId, string adminEmail, string adminPassword) { try { using (_currentTenant.Change(tenantId)) { // 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(); } // 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); } }
public async Task BuildInternalAsync() { await _dataSeeder.SeedAsync(); }
//[Authorize(Policy = "HasAdminRole")] public async Task <IActionResult> Get() { await _dataSeeder.SeedAsync(); return(NoContent()); }
public static Task SeedAsync(this IDataSeeder seeder, Guid?tenantId = null) { return(seeder.SeedAsync(new DataSeedContext(tenantId))); }
private async Task SeedDataAsync() { await dataSeeder.SeedAsync(new DataSeedContext()); }
private async Task SeedDataAsync() { Logger.LogInformation("Executing database seed..."); await _dataSeeder.SeedAsync(); }
private async Task SeedDataAsync() { Logger.LogInformation($"Executing host database seed..."); await _dataSeeder.SeedAsync(new DataSeedContext()); }
private async Task SeedDataAsync(Tenant tenant = null) { Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); await _dataSeeder.SeedAsync(tenant?.Id); }
private static async Task ResetDataAsync(OperationContext context, IDataSeeder dataSeeder, SeedData seedData, IServiceHttpClientFactory serviceClientFactory) { await dataSeeder.SeedAsync(seedData); await ClearCacheAsync(context, serviceClientFactory); }