public static void Initialize(SpaDbContext context)
        {
            context.Database.EnsureCreated();

            if (context.User.Any())
            {
                return;   // DB has been seeded
            }

            context.SaveChanges();
        }
        public static void Initialize(SpaDbContext context)
        {
            context.Database.EnsureCreated();

            if (context.User.Any())
            {
                return;   // DB has been seeded
            }
            var users = new Users[]
            {
                new Users()
                {
                    Name = "Mark Pieszak"
                },
                new Users()
                {
                    Name = "Abrar Jahin"
                },
                new Users()
                {
                    Name = "hakonamatata"
                },
                new Users()
                {
                    Name = "LiverpoolOwen"
                },
                new Users()
                {
                    Name = "Ketrex"
                },
                new Users()
                {
                    Name = "markwhitfeld"
                },
                new Users()
                {
                    Name = "daveo1001"
                },
                new Users()
                {
                    Name = "paonath"
                },
                new Users()
                {
                    Name = "nalex095"
                },
                new Users()
                {
                    Name = "ORuban"
                },
                new Users()
                {
                    Name = "Gaulomatic"
                }
            };

            foreach (Users s in users)
            {
                context.User.Add(s);
            }
            context.SaveChanges();
        }
示例#3
0
        public static void Initialize(SpaDbContext context)
        {
            //context.Database.EnsureDeleted();
            //context.Database.Migrate();
            context.Database.EnsureCreated();

            //initialize users
            if (!context.User.Any())
            {
                var users = new User[]
                {
                    new User()
                    {
                        Name = "Mark Pieszak"
                    },
                    new User()
                    {
                        Name = "Abrar Jahin"
                    },
                    new User()
                    {
                        Name = "hakonamatata"
                    },
                    new User()
                    {
                        Name = "LiverpoolOwen"
                    },
                    new User()
                    {
                        Name = "Ketrex"
                    },
                    new User()
                    {
                        Name = "markwhitfeld"
                    },
                    new User()
                    {
                        Name = "daveo1001"
                    },
                    new User()
                    {
                        Name = "paonath"
                    },
                    new User()
                    {
                        Name = "nalex095"
                    },
                    new User()
                    {
                        Name = "ORuban"
                    },
                    new User()
                    {
                        Name = "Gaulomatic"
                    }
                };

                foreach (User s in users)
                {
                    context.User.Add(s);
                }
                context.SaveChanges();
            }
        }