Example #1
0
        public void CreateDatabase()
        {
            var dbManager = new DatabaseManager(_DbProvider, _connectionString);
            
            // Check if database exists.. (and create it if needed)
            if (!dbManager.DatabaseExists())
            {
                dbManager.CreateDatabase();
                new SchemaExport(_builtConfiguration).Create(false, true);

                if (_DbProvider == DbProvider.MsSqlProvider)
                {
                    using (var conn = new SqlConnection(_connectionString))
                    {
                        try
                        {
                            conn.Open();
                            using (var cmd = conn.CreateCommand())
                            {
                                cmd.CommandText = "RENAME_UNIQUE_KEYS";
                                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                                cmd.ExecuteNonQuery();
                            }
                        }
                        finally
                        {
                            conn.Close();
                        }
                    }
                }
            }
        }
Example #2
0
        public void DeleteDatabase()
        {
            var dbManager = new DatabaseManager(_DbProvider, _connectionString);

            if (dbManager.DatabaseExists())
                dbManager.DropDatabase();
        }
Example #3
0
 public bool DatabaseExists()
 {
     var dbManager = new DatabaseManager(_DbProvider, _connectionString);
     return dbManager.DatabaseExists();
 }