示例#1
0
        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;
            }
        }
示例#2
0
 protected async Task <T> GetConnection <T>(Func <MySqlConnection, Task <T> > func)
 {
     using (var conn = _factory.GetConnection())
     {
         return(await func(conn).ConfigureAwait(false));
     }
 }
示例#3
0
        public DatabaseFixture()
        {
            ConnectionFactory = new MySqlConnectionFactory(TestConfig.ConnectionOptions);

            using (var conn = ConnectionFactory.GetConnection())
            {
                conn.Execute($"create schema if not exits {TestConfig.Schema}");
            }
        }