Beispiel #1
0
        public void BuildSchema()
        {
            var dialect = Dialect.GetDialect(configuration.Properties);
            var drops   = configuration.GenerateDropSchemaScript(dialect);

            ExecuteSqlScripts(drops);

            var scripts = configuration.GenerateSchemaCreationScript(dialect);

            ExecuteSqlScripts(scripts);
        }
        // Create database schema
        private static void ReCreateSchema(NHibernate.Cfg.Configuration cfg)
        {
            Dialect dialect = Dialect.GetDialect(cfg.Properties);

            using (var conn = new SqlConnection(cfg.GetProperty(NHibernate.Cfg.Environment.ConnectionString)))
            {
                conn.Open();

                foreach (string cmdText in cfg.GenerateDropSchemaScript(dialect).Union(cfg.GenerateSchemaCreationScript(dialect)))
                {
                    using (var cmd = new SqlCommand(cmdText, conn))
                    {
                        cmd.ExecuteNonQuery();
                    }
                }
            }
        }