Ejemplo n.º 1
0
        protected override void Seed(Data.DataModels.CFContext context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.
            try
            {
                InitDatabaseProvider.SetupRolesGroups(context);
                InitDatabaseProvider.GrantDefaultRolesForGroups(context);
                InitDatabaseProvider.CreateSuperUser(context);

                //InitDatabaseProvider.CreateSlide(context);
                //InitDatabaseProvider.CreatePage(context);
                //InitDatabaseProvider.CreateContactDetail(context);
                //InitDatabaseProvider.CreateConfigTitle(context);
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     InitDatabaseProvider.CreateStdType();
     InitDatabaseProvider.CreateStandard();
     InitDatabaseProvider.CreatEquGroup();
     InitDatabaseProvider.CreateStatus();
     InitDatabaseProvider.CreatCompany();
 }
Ejemplo n.º 3
0
            public override void InitializeDatabase(CFContext context)
            {
                if (!context.Database.Exists())
                {
                    // if database did not exist before - create it
                    context.Database.Create();
                    InitDatabaseProvider.SetupRolesGroups(context);
                    InitDatabaseProvider.GrantDefaultRolesForGroups(context);
                    InitDatabaseProvider.CreateSuperUser(context);
                    InitDatabaseProvider.CreateStdType();
                    InitDatabaseProvider.CreateStandard();
                    InitDatabaseProvider.CreatEquGroup();
                    InitDatabaseProvider.CreateStatus();


                    InitDatabaseProvider.CreateSlide(context);
                    InitDatabaseProvider.CreatePage(context);
                    InitDatabaseProvider.CreateContactDetail(context);
                    InitDatabaseProvider.CreateConfigTitle();
                }
                else
                {
                    // query to check if MigrationHistory table is present in the database
                    var migrationHistoryTableExists = ((IObjectContextAdapter)context).ObjectContext.ExecuteStoreQuery <int>(
                        string.Format(
                            "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '{0}' AND table_name = '__MigrationHistory'",
                            "dbo"));

                    // if MigrationHistory table is not there (which is the case first time we run) - create it

                    if (migrationHistoryTableExists.FirstOrDefault() == 0)
                    {
                        context.Database.Delete();
                        context.Database.Create();
                        InitDatabaseProvider.SetupRolesGroups(context);
                        InitDatabaseProvider.GrantDefaultRolesForGroups(context);
                        InitDatabaseProvider.CreateSuperUser(context);
                        InitDatabaseProvider.CreateStdType();
                        InitDatabaseProvider.CreateStandard();
                        InitDatabaseProvider.CreatEquGroup();
                        InitDatabaseProvider.CreateStatus();


                        InitDatabaseProvider.CreateSlide(context);
                        InitDatabaseProvider.CreatePage(context);
                        InitDatabaseProvider.CreateContactDetail(context);
                        InitDatabaseProvider.CreateConfigTitle();
                    }
                }
            }