// Seeds data into Mock LandmarkingContext db public static void Seed(this LandmarkingContext dbContext) { // retreive JSON user data var userData = System.IO.File.ReadAllText("Data/userData.json"); var users = JsonConvert.DeserializeObject <List <User> >(userData); // Add Users for DbContext instance foreach (var user in users) { byte[] passwordHash, passwordSalt; CreatePasswordHash("password", out passwordHash, out passwordSalt); user.PasswordSalt = passwordSalt; user.PasswordHash = passwordHash; user.Username = user.Username.ToLower(); dbContext.Add(user); } dbContext.SaveChanges(); }
//Add new entity to database public void Add <T>(T entity) where T : class { _context.Add(entity); }