private static void RunMigrations(string databaseName, TodoDbContext todoDbContext, ILogger logger) { logger.LogInformation("About to delete test database {TestDatabaseName} ...", databaseName); bool hasDeleteDatabase = todoDbContext.Database.EnsureDeleted(); logger.LogInformation( hasDeleteDatabase ? "Test database {TestDatabaseName} has been successfully deleted" : "Could not find any test database {TestDatabaseName} to delete", databaseName); logger.LogInformation("About to run migrations against test database {TestDatabaseName} ...", databaseName); IMigrator databaseMigrator = todoDbContext.GetInfrastructure().GetRequiredService <IMigrator>(); databaseMigrator.Migrate(); logger.LogInformation("Migrations have been successfully run against test database {TestDatabaseName}", databaseName); }
private static void RunMigrations(string databaseName, TodoDbContext todoDbContext, ILogger logger) { logger.LogInformation("About to delete test database {TestDatabaseName} ...", databaseName); bool hasDeleteDatabase = todoDbContext.Database.EnsureDeleted(); // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression if (hasDeleteDatabase) { logger.LogInformation("Test database {TestDatabaseName} has been successfully deleted", databaseName); } else { logger.LogInformation("Could not find any test database {TestDatabaseName} to delete", databaseName); } logger.LogInformation("About to run migrations against test database {TestDatabaseName} ...", databaseName); IMigrator databaseMigrator = todoDbContext.GetInfrastructure().GetRequiredService <IMigrator>(); databaseMigrator.Migrate(); logger.LogInformation("Migrations have been successfully run against test database {TestDatabaseName}", databaseName); }