public void Execute() { try { using (var conn = _connectionFactory.GetConnection()) { conn.Open(); _logger.LogInformation("MySQL connectivity OK!"); var evolve = new Evolve(conn, msg => _logger.LogInformation(msg)) { EmbeddedResourceAssemblies = new[] { typeof(MySqlServerVerificationStartupAction).Assembly }, IsEraseDisabled = true }; evolve.Migrate(); } } catch (Exception ex) { _logger.LogError(ex, "Failed to connect to MySQL"); throw; } }
protected async Task <T> GetConnection <T>(Func <MySqlConnection, Task <T> > func) { using (var conn = _factory.GetConnection()) { return(await func(conn).ConfigureAwait(false)); } }
public DatabaseFixture() { ConnectionFactory = new MySqlConnectionFactory(TestConfig.ConnectionOptions); using (var conn = ConnectionFactory.GetConnection()) { conn.Execute($"create schema if not exits {TestConfig.Schema}"); } }