Exemplo n.º 1
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new MSAContext(
                serviceProvider.GetRequiredService <
                    DbContextOptions <MSAContext> >()))
     {
         if (context.User.Any())
         {
             return;   // DB has been seeded
         }
         var users = UserGenerator.GenerateUsers();
         foreach (User user in users)
         {
             context.User.AddRange(user);
         }
         Console.WriteLine("DB seeded.");
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public void Save()
 {
     context.SaveChanges();
 }