Tag: seed

如何在ASP .NET MVC 5中为AspNetUser创建SecurityStamp

当我通过Register操作创建用户时,应用程序用户运行SecurityStamp。 当我添加用户时: if (!context.Users.Any()) { System.Diagnostics.Debug.WriteLine(“INSIDE”); var hasher = new PasswordHasher(); try { var users = new List { new ApplicationUser{PasswordHash = hasher.HashPassword(“TestPass44!”), Email = “informatyka4444@wp.pl”, UserName = “informatyka4444@wp.pl”}, new ApplicationUser{PasswordHash = hasher.HashPassword(“TestPass44!”), Email = “informatyka4445@wp.pl”, UserName = “informatyka4445@wp.pl”} }; users.ForEach(user => context.Users.AddOrUpdate(user)); context.SaveChanges(); } catch (DbEntityValidationException e) { System.Diagnostics.Debug.WriteLine(“EXC: “); foreach (DbEntityValidationResult result in […]