Ejemplo n.º 1
0
        private void SeedInMem()
        {
            using (var context = new UserDbContext(options))
            {
                var users = new List <User>
                {
                    new User {
                        FirstName = "Simon", Surname = "Robinson", Started = DateTime.Parse("2001-09-01"), Left = DateTime.Parse("2002-10-01")
                    },
                    new User {
                        FirstName = "Jacob", Surname = "Robinson", Started = DateTime.Parse("2001-10-01"), Left = DateTime.Parse("2002-10-01")
                    },
                    new User {
                        FirstName = "Alex", Surname = "Wilson", Started = DateTime.Parse("2008-06-01"), Left = DateTime.Parse("2012-10-01")
                    },
                    new User {
                        FirstName = "Nadia", Surname = "Wilson", Started = DateTime.Parse("2007-05-01"), Left = DateTime.Parse("2012-10-01")
                    },
                    new User {
                        FirstName = "Reuben", Surname = "Wilson", Started = DateTime.Parse("2009-04-01"), Left = DateTime.Parse("2012-10-01")
                    },
                    new User {
                        FirstName = "Jenny", Surname = "Jones", Started = DateTime.Parse("2016-02-01"), Left = DateTime.Parse("2020-10-01")
                    },
                    new User {
                        FirstName = "Leroy", Surname = "Shirto", Started = DateTime.Parse("2004-08-01"), Left = DateTime.Parse("2012-09-01")
                    }
                };

                context.AddRange(users);
                context.SaveChanges();
            }
        }
Ejemplo n.º 2
0
 internal static void Save(List <User> users, UserDbContext userDbContext)
 {
     userDbContext.AddRange(users);
     userDbContext.SaveChanges();
 }