public GenericRepository(TweeterAppDbContext context) { if (context == null) { throw new ArgumentException("An instance of DbContext is required to use this repository.", "context"); } this.Context = context; this.DbSet = this.Context.Set <T>(); }
private void SeedUsers(TweeterAppDbContext context) { var adminUser = new User { Email = "*****@*****.**", UserName = "******" }; this.userManager.Create(adminUser, "123456"); this.userManager.AddToRole(adminUser.Id, "Admin"); }
protected override void Seed(TweeterAppDbContext context) { if (context.Users.Any()) { return; } this.userManager = new UserManager <User>(new UserStore <User>(context)); this.SeedRoles(context); this.SeedUsers(context); base.Seed(context); }
private void SeedRoles(TweeterAppDbContext context) { context.Roles.AddOrUpdate(x => x.Name, new IdentityRole("Admin")); context.SaveChanges(); }