Example #1
0
 public static void SeedUsers(UserDbContext dataContext)
 {
     if (!dataContext.users.Any())
     {
         var    userData = System.IO.File.ReadAllText("Data/UserSeedData.json");
         var    users    = JsonConvert.DeserializeObject <List <User> >(userData);
         byte[] passwordhash, passwordSalt;
         foreach (var user in users)
         {
             CreatePwdHash("password", out passwordhash, out passwordSalt);
             user.passwordHash = passwordhash;
             user.passwordSalt = passwordSalt;
             user.Username     = user.Username.ToLower();
             dataContext.users.Add(user);
         }
         dataContext.SaveChanges();
     }
 }