private static void CreateAndInitializeDatabaseIfNotExists() { var recreateDatabaseSql = String.Format( @"if db_id('{0}') is null create database [{0}] COLLATE SQL_Latin1_General_CP1_CS_AS", ConnectionUtils.GetDatabaseName()); using (var connection = new SqlConnection( ConnectionUtils.GetMasterConnectionString())) { connection.Execute(recreateDatabaseSql); } using (var connection = new SqlConnection( ConnectionUtils.GetConnectionString())) { SqlServerObjectsInstaller.Install(connection, null, true); } }
private static void RecreateDatabaseAndInstallObjects() { var recreateDatabaseSql = String.Format( @"if db_id('{0}') is null create database [{0}]", ConnectionUtils.GetDatabaseName()); using (var connection = new SqlConnection( ConnectionUtils.GetMasterConnectionString())) { connection.Execute(recreateDatabaseSql); } using (var connection = new SqlConnection( ConnectionUtils.GetConnectionString())) { SqlServerObjectsInstaller.Install(connection); } }