예제 #1
0
        private void DropDatabase()
        {
            var sb     = new SqlConnectionStringBuilder(_settings.ConnectionString);
            var dbName = sb.InitialCatalog;

            sb.InitialCatalog = "master";

            using var dbConnection = new SqlConnection(sb.ConnectionString);
            dbConnection.Open();
            var command = dbConnection.CreateCommand();

            command.CommandText = SqlScripts.DropDb(dbName);
            command.ExecuteNonQuery();
        }
        private static void CreateDatabase()
        {
            var sb     = new SqlConnectionStringBuilder(TestDbConnectionString);
            var dbName = sb.InitialCatalog;

            sb.InitialCatalog = "master";

            using (IDbConnection dbConnection = new SqlConnection(sb.ConnectionString))
            {
                dbConnection.Open();
                var command = dbConnection.CreateCommand();
                command.CommandText = SqlScripts.CreateDb(dbName);
                command.ExecuteNonQuery();
            }
        }