示例#1
0
        static void InitDbScheme(IUtHelper utHelper, bool recreateDb = false)
        {
            JsonHelper.JsonSerialize = new NhJsonSerialize();

            NHibernateProfiler.Initialize();

            //FluentNhibernateConvertions.Conventions.Add(new Nb_ForeignKeyConstraintNameConvention());
            //DbSettingHelper.ShowSql = true;
            //DbSettingHelper.ConnString = @"Data Source=.;AttachDbFilename=|DataDirectory|\App_Data\DemoDb.mdf;Integrated Security=True;Connect Timeout=30";

            var dbName     = "DemoDb";
            var connString = string.Format(@"Data Source=.;Initial Catalog={0};Persist Security Info=True;User ID=sa;Password=zqnb_123", dbName);

            DbSettingHelper.ConnString = connString;

            var sqlScriptHelper = new SqlScriptHelper();

            if (recreateDb)
            {
                sqlScriptHelper.ReCreateDbIfExist(connString, dbName);
            }
            else
            {
                sqlScriptHelper.CreateDbIfNotExist(connString, dbName);
            }

            utHelper.SetUpNHibernate(recreateDb, typeof(Program));
            ShowSplit("Setup Done!");
            Console.WriteLine();
        }
示例#2
0
        public virtual void CreateDbIfNotExist(string dbserver, string dbname, string dbuser, string dbpassword)
        {
            SqlScriptHelper helper = new SqlScriptHelper();

            helper.CreateDbIfNotExist(dbserver, dbname, dbuser, dbpassword);
        }