protected override void Seed(Context context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. E.g. // // context.People.AddOrUpdate( // p => p.FullName, // new Person { FullName = "Andrew Peters" }, // new Person { FullName = "Brice Lambson" }, // new Person { FullName = "Rowan Miller" } // ); // var userStore = new UserStore<ApplicationUser>(context); var mngr = new UserManager<ApplicationUser>(userStore); context.Roles.AddOrUpdate(r => r.Name, new IdentityRole { Name = "Administrators" }); ApplicationUser adm = new ApplicationUser(); adm.Email = "*****@*****.**"; adm.UserName = "******"; mngr.Create(adm, "Adm!n0"); context.SaveChanges(); IdentityRole adrol = context.Roles.First(x => x.Name == "Administrators"); adm = mngr.FindByEmail("*****@*****.**"); mngr.AddToRole(adm.Id, adrol.Name); context.SaveChanges(); }
public void pubSeed(Context context) { this.Seed(context); }