MVC 5 Seed Users and Roles

前端 未结 7 1815
有刺的猬
有刺的猬 2020-11-28 01:56

I have been playing about with the new MVC 5, I have a few models, controller and views setup using code first migrations.

My question is how do I seed users and ro

相关标签:
7条回答
  • 2020-11-28 02:45

    It's a small addition, but to anyone having the "UserId not found." message when trying to seed: (Tom Regan had this question in the comments, and I was stuck on it myself for a while)

    This means that the manager.Create(user, "ChangeItAsap!") was not successful. This might have a different reason, but for me it was because my password was not succeeding its validation.

    I had a custom passwordvalidator, which was not being called when seeding the database, so the validation rules i was used to (minlength 4 instead of default 6) did not apply. Make sure your password (and all other fields for that matter) is passing validation.

    0 讨论(0)
提交回复
热议问题