Exemple #1
0
 /* Seeding the DB*/
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var scope = serviceProvider.CreateScope())
     {
         using (var context = scope.ServiceProvider.GetRequiredService <campsContext>())
         {
             if (!context.Users.Any())
             {
                 string         salt = SaltGenerator.SaltMethod();
                 HashingService hash = new HashingService();
                 context.Users.Add(new Users()
                 {
                     Fullname = "Admin", Email = "*****@*****.**", Passwordsalt = salt, Role = Role.Admin, Passwordhash = hash.ComputeSha256Hash("Admin", salt)
                 });
                 context.SaveChanges();
             }
             //Seed all the other stuff
         }
     }
 }