public void SetDatabaseInitializer()
        {
            var initializer = new CreateTablesIfNotExist <LxsObjectContext>();

            Database.SetInitializer(initializer);
            // Database.SetInitializer(new CreateDatabaseIfNotExists<LxsObjectContext>());
        }
Exemple #2
0
        /// <summary>
        /// Set database initializer
        /// </summary>
        public override void SetDatabaseInitializer()
        {
            var customCommands = new List <string>();

            var initializer = new CreateTablesIfNotExist <NopObjectContext>(customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
        /// <summary>
        /// Set database initializer
        /// </summary>
        public virtual void SetDatabaseInitializer()
        {
            var tablesToValidate = new[] { "quote" };
            var customCommands   = new List <string>();

            var initializer = new CreateTablesIfNotExist <KomodoContext>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
        public void SetDatabaseInitializer()
        {
            // Danh sách các bảng cần phải có trong DB
            var tablesToValidate = new string[] { "Student", "Role" };

            var initializer = new CreateTablesIfNotExist <AppObjectContext>(tablesToValidate);

            Database.SetInitializer(initializer);
            //Database.SetInitializer(new DropCreateDatabaseIfModelChanges<AppObjectContext>());
        }
        public void SetDatabaseInitializer()
        {
            var customCommands = new List<string>();
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist<GatherObjectContext>(customCommands.ToArray());
            Database.SetInitializer(initializer);
            //Database.SetInitializer(new CreateDatabaseIfNotExists<GatherObjectContext>());
            //Database.SetInitializer(new CreateDatabaseIfNotExistsInitializer());
            //Database.SetInitializer(new MigrateDatabaseToLatestVersion<GatherObjectContext, DbMigrationsConfiguration<GatherObjectContext>>());
        }
Exemple #6
0
        /// Set database initializer        /// </summary>
        public virtual void SetDatabaseInitializer()
        {                                                                                                              //pass some table names to ensure that we have nopCommerce 2.X installed
            var tablesToValidate = new[] { "Customer", "Discount", "Order", "Product", "ShoppingCartItem" };           //custom commands (stored proedures, indexes)

            var customCommands = new List <string>();                                                                  //use webHelper.MapPath instead of HostingEnvironment.MapPath which is not available in unit tests

            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/MySql.Indexes.sql"), false)); //use webHelper.MapPath instead of HostingEnvironment.MapPath which is not available in unit tests
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/MySql.StoredProcedures.sql"), false));
            var initializer = new CreateTablesIfNotExist <SiteObjectContext>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
Exemple #7
0
        /// <summary>
        ///
        /// </summary>
        public virtual void SetDatabaseInitializer()
        {
            var tableNamesValidate = new[] { "Customer", "Discount", "Order", "Product", "ShoppingCartItem" };
            var customCommands     = new List <string>();

            customCommands.AddRange(ParseComands(HostingEnvironment.MapPath("~/App_Data/Install/SqlServer.Indexes.sql"), false));
            customCommands.AddRange(ParseComands(HostingEnvironment.MapPath("~/App_Data/Install/SqlServer.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist <NopObjectContext>(tableNamesValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
        /// <summary>
        /// 设置数据库初始化程序
        /// </summary>
        public void SetDatabaseInitializer()
        {
            //var tablesToValidate = new[] { "Customer", "Discount", "Order", "Product", "ShoppingCartItem" };
            var tablesToValidate = new[] { "Discount", "Order", "ShoppingCartItem" };
            var customCommands   = new List <string>();

            customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/Install/SqlServer.Indexes.sql"), false));
            customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/Install/SqlServer.StoredProcedures.sql"), false));
            var initlializer = new CreateTablesIfNotExist <FrameworkObjectContext>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initlializer);
        }
        public virtual void SetDatabaseInitializer()
        {
            // 1 vài tên bảng để kiểm tra rằng chúng ta đăng sử dụng nop phiên bnar 2.x ( những bảng này sẽ chỉ có trên nop 2.x )
            var tablesToValidate = new[] { "Customer", "Discount", "Order", "Product", "ShoppingCartItem" };

            // lấy lên các lệnh custom cần thực thi ( store, index )
            var customCommands = new List<string>();
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/Install/SqlServer.Indexes.sql"), false));
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/Install/SqlServer.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist<NopObjectContext>(tablesToValidate, customCommands.ToArray());
            Database.SetInitializer(initializer);
        }
Exemple #10
0
        /// <summary>
        /// 初始化SqlServer数据库设置
        /// </summary>
        public virtual void SetDatabaseInitializer()
        {
            var tablesToValidate = new string[] { };

            var customCommands = new List <string>();

            customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/Install/SqlServer.Indexes.sql"), false));
            customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/Install/SqlServer.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist <EntityContext>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
Exemple #11
0
        /// <summary>
        /// Set database initializer
        /// </summary>
        public virtual void SetDatabaseInitializer()
        {
            //pass some table names to ensure that we have App installed
            var tablesToValidate = new[] { "ChatLieu", "SanPham", "KhachHang" };
            var customCommands   = new List <string>();

            customCommands.AddRange(ParseCommands(Path.Combine(CommonHelper.MapPath("~/Settings/"), "schema.sql"), false));
            customCommands.AddRange(ParseCommands(Path.Combine(CommonHelper.MapPath("~/Settings/"), "update.sql"), false));
            var initializer = new CreateTablesIfNotExist <AppContext>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
            //Database.SetInitializer<AppContext>(null);
        }
        public override void SetDatabaseInitializer()
        {
            //pass some table names to ensure that we have nopCommerce 2.X installed
            var tablesToValidate = new[] {"Customer", "Discount", "Order", "Product", "ShoppingCartItem"};

            //custom commands (stored proedures, indexes)

            var customCommands = new List<string>();
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/SqlServer.Indexes.sql"), false));
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/SqlServer.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist<NopObjectContext>(tablesToValidate, customCommands.ToArray());
            Database.SetInitializer<NopObjectContext>(initializer);
        }
        /// <summary>
        /// Set database initializer
        /// </summary>
        public override void SetDatabaseInitializer()
        {
            //pass some table names to ensure that we have nopCommerce 2.X installed
            var tablesToValidate = new string[] { };

            //custom commands (stored proedures, indexes)

            var customCommands = new List <string>();

            customCommands.AddRange(ParseCommands(Utils.MapPath("~/App_Data/SqlServer.Indexes.sql"), false));

            var initializer = new CreateTablesIfNotExist <PmSoftObjectContext>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
        public virtual void VeritabanıBaşlatıcıyıAyarla()
        {
            var DoğrulananTablolar = new[] { "Kullanıcılar", "İndirim", "Sipariş" };

            //custom commands (stored procedures, indexes)

            var özelKomutlar = new List <string>();

            özelKomutlar.AddRange(KomutlarıAyrıştır(GenelYardımcı.MapPath("~/App_Data/Install/SqlServer.Indexes.sql"), false));
            özelKomutlar.AddRange(KomutlarıAyrıştır(GenelYardımcı.MapPath("~/App_Data/Install/SqlServer.StoredProcedures.sql"), false));

            var başlatıcı = new CreateTablesIfNotExist <TSObjectContext>(DoğrulananTablolar, özelKomutlar.ToArray());

            Database.SetInitializer(başlatıcı);
        }
Exemple #15
0
        /// <summary>
        /// 设置一个数据库初始化
        /// </summary>
        public virtual void SetDatabaseInitializer()
        {
            //通过一些表名,来确保系统可以正确被安装
            //var tablesToValidate = new[] { "Customer", "Discount", "Order", "Product", "ShoppingCartItem" };
            var tablesToValidate = new[] { "Customer" };
            //用户命令
            var customCommands = new List <string>();

            //在单元测试中是不可用的webhelper.mappath
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/SqlServer.Indexes.sql"), false));
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/SqlServer.sitedProcedures.sql"), false));
            var initializer = new CreateTablesIfNotExist <ObjectContextExt>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
Exemple #16
0
        /// <summary>
        /// Set database initializer
        /// </summary>
        public virtual void SetDatabaseInitializer() {
            //pass some table names to ensure that we have nopCommerce 2.X installed
            var tablesToValidate = new[] { "UserRole", "PermissionRecord", "Language", "LocaleStringResource" };

            //custom commands (stored proedures, indexes)

            var customCommands = new List<string>();
            //use webHelper.MapPath instead of HostingEnvironment.MapPath which is not available in unit tests
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/Install/MySql.Indexes.sql"), false));
            //use webHelper.MapPath instead of HostingEnvironment.MapPath which is not available in unit tests
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/Install/MySql.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist<NutObjectContext>(tablesToValidate, customCommands.ToArray());
            Database.SetInitializer(initializer);
        }
Exemple #17
0
        /// <summary>
        /// Set database initializer
        /// </summary>
        public virtual void SetDatabaseInitializer()
        {
            //pass some table names to ensure that we have nopCommerce 2.X installed
            var tablesToValidate = new[] { "Organization", "Users" };

            //custom commands (stored procedures, indexes)

            var customCommands = new List <string>();
            //customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/Install/SqlServer.Indexes.sql"), false));
            //customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/Install/SqlServer.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist <MstDbContext>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
        /// <summary>
        /// Set database initializer
        /// </summary>
        public override void SetDatabaseInitializer()
        {
            //In case you want to add indexes or sprocs after the DB is created, uncomment this code.
            //Use HostingEnvironment to MapPath to a specific folder in the website.

            //custom commands (stored proedures, indexes)

            //var customCommands = new List<string>();
            //customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/SqlServer.Indexes.sql"), false));
            //customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/SqlServer.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist<EFCustomContext>(tablesToValidate: new[] { "" }, customCommands: new[] { "" });

            Database.SetInitializer(initializer);
        }
        /// <summary>
        /// Set database initializer
        /// </summary>
        public virtual void SetDatabaseInitializer()
        {
            //pass some table names to ensure that we have Campray 2.X installed
            var tablesToValidate = new[] { "Customer", "Discount", "Order", "Product", "ShoppingCartItem" };

            //custom commands (stored proedures, indexes)

            var customCommands = new List<string>();
            //use webHelper.MapPath instead of HostingEnvironment.MapPath which is not available in unit tests
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/Install/SqlServer.Indexes.sql"), false));
            //use webHelper.MapPath instead of HostingEnvironment.MapPath which is not available in unit tests
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/Install/SqlServer.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist<NopObjectContext>(tablesToValidate, customCommands.ToArray());
            Database.SetInitializer(initializer);
        }
Exemple #20
0
        /// <summary>
        /// Set database initializer
        /// </summary>
        public virtual void SetDatabaseInitializer()
        {
            //pass some table names to ensure that we have nopCommerce 2.X installed
            var tablesToValidate = new[] { "Customer", "Discount", "Order", "Product", "ShoppingCartItem" };

            //custom commands (stored procedures, indexes)

            var customCommands = new List <string>();

            customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/Install/SqlServer.Indexes.sql"), false));
            customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/Install/SqlServer.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist <NopObjectContext>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
        /// <summary>
        /// Set database initializer
        /// </summary>
        public virtual void SetDatabaseInitializer()
        {
            //pass some table names to ensure that we have AjeerLink installed
            var tablesToValidate = new[] { "MOL_User", "Lookup_Job", "MOL_Establishment", "MOL_Laborer", "MOL_Owner" };

            //custom commands (stored proedures, indexes)

            var customCommands = new List <string>();
            //use webHelper.MapPath instead of HostingEnvironment.MapPath which is not available in unit tests
            //customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/SqlServer.Indexes.sql"), false));
            //use webHelper.MapPath instead of HostingEnvironment.MapPath which is not available in unit tests
            //customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/SqlServer.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist <IndividualsServicesObjectContext>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
Exemple #22
0
        /// <summary>
        /// Set database initializer
        /// </summary>
        public override void SetDatabaseInitializer()
        {
            var tablesToValidate = new[] { "businesses", "users" };

            //custom commands (stored proedures, indexes)

            var customCommands = new List <string>();

            //use webHelper.MapPath instead of HostingEnvironment.MapPath which is not available in unit tests
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/MySql.Indexes.sql"), false));
            //use webHelper.MapPath instead of HostingEnvironment.MapPath which is not available in unit tests
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/MySql.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist <AppObjectContext>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
        /// <summary>
        /// Set database initializer设置数据库初始化
        /// </summary>
        public virtual void SetDatabaseInitializer()
        {
            //如果需要创建表可修改这里

            //pass some table names to ensure that we have nopCommerce 2.X installed
            //传递一些表名以确保我们有nopCommerce 2.X安装
            var tablesToValidate = new[] { "User" };

            //custom commands (stored procedures, indexes)
            //自定义命令(存储过程、索引)
            var customCommands = new List <string>();

            customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/Install/SqlServer.Indexes.sql"), false));
            customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/Install/SqlServer.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist <NopObjectContext>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
        /// <summary>
        /// Set database initializer
        /// </summary>
        public override void SetDatabaseInitializer()
        {
            //pass some table names to ensure that we have the system installed
            var tablesToValidate = new[] { "Port" };

            //custom commands (stored proedures, indexes)
            var customCommands = new List<string>();

            /*
             * Commenting the below installation process as this is not required
             *
             * customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/SqlServer.Functions.sql"), false));
             * customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/SqlServer.Indexes.sql"), false));
             * customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/SqlServer.StoredProcedures.sql"), false));
            */

            var initializer = new CreateTablesIfNotExist<SiteObjectContext>(tablesToValidate, customCommands.ToArray());
            Database.SetInitializer(initializer);
        }
Exemple #25
0
        /// <summary>
        /// Set database initializer
        /// </summary>
        public virtual void SetDatabaseInitializer()
        {
            //pass some table names to ensure
            var tablesToValidate = new[] { "Customer", "Cars" };

            tablesToValidate = null;

            //custom commands (stored proedures, indexes)

            var customCommands = new List <string>();

            //use webHelper.MapPath instead of HostingEnvironment.MapPath which is not available in unit tests
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/Install/SqlServer.Indexes.sql"), false));
            //use webHelper.MapPath instead of HostingEnvironment.MapPath which is not available in unit tests
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/Install/SqlServer.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist <AppObjectContext>(tablesToValidate, customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
Exemple #26
0
        public virtual void SetDatabaseInitializer()
        {
            var context = (BMObjectContext)EngineContext.Current.Resolve <IDbContext>();

            var databaseExist = context.Database.Exists();

            if (!databaseExist)
            {
                var connectionString = context.Database.Connection.ConnectionString;
                var builder          = new SqlConnectionStringBuilder(connectionString);
                var databaseName     = builder.InitialCatalog;

                //If database not exist, will throw wrong. So create connection string to 'master' database. It always exists.
                builder.InitialCatalog = "master";

                var masterCatalogConnectionString = builder.ToString();

                var script = $"CREATE DATABASE [{databaseName}]";

                using (var conn = new SqlConnection(masterCatalogConnectionString))
                {
                    conn.Open();
                    using (var command = new SqlCommand(script, conn))
                    {
                        command.ExecuteNonQuery();
                    }
                }
            }


            var customCommands = new List <string>();

            customCommands.AddRange(ParseCommands(CommonHelper.MapPath("~/App_Data/Install/SqlServer.StoredProcedures.sql"), true));

            var initializer = new CreateTablesIfNotExist <BMObjectContext>(customCommands.ToArray());

            Database.SetInitializer(initializer);
        }
Exemple #27
0
 public virtual void SetDatabaseInitializer()
 {
     //pass some table names to ensure that we have nopCommerce 2.X installed
     var initializer = new CreateTablesIfNotExist<CMSContext>(new[] { "Module", "ModuleType" });
     Database.SetInitializer<CMSContext>(initializer);
 }
        /// <summary>
        ///     Establece el inicio de la base de datos
        /// </summary>
        public virtual void SetDatabaseInitializer()
        {
            //Paso algunas tablas a buscar
            var tablesToValidate = new[] { "User" };

            //Comandos personalizados (StoreProcedure, indexes)
            var customCommands = new List<string>();
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/Install/SqlServer.Indexes.sql"), false));
            customCommands.AddRange(ParseCommands(HostingEnvironment.MapPath("~/App_Data/Install/SqlServer.StoredProcedures.sql"), false));

            var initializer = new CreateTablesIfNotExist<SoftContext>(tablesToValidate, customCommands.ToArray());
            Database.SetInitializer(initializer);
        }
        public void Execute()
        {
            var initializer = new CreateTablesIfNotExist <NoisObjectContext>(new string[0], new string[0]);

            Database.SetInitializer(initializer);
        }
Exemple #30
0
        public void SetDatabaseInitializer()
        {
            var initializer = new CreateTablesIfNotExist <DbgoObjectContext>();

            Database.SetInitializer(initializer);
        }