public void SeedUsers() { if (!context.Users.Any()) { var userData = System.IO.File.ReadAllText("Data/UserSeedData.json"); var users = JsonConvert.DeserializeObject <List <User> >(userData); foreach (var user in users) { byte[] passwordHash, passwordSalt; CreatePasswordHash("password", out passwordHash, out passwordSalt); user.Username = user.Username.ToLower(); user.PasswordHash = passwordHash; user.PasswordSalt = passwordSalt; context.Add(user); } context.SaveChanges(); } }
public void Add <T>(T entity) where T : class { context.Add(entity); }