简体   繁体   中英

Seeding Admin account with Identity 2 in .Net without Entity Framework

I'm looking for advice here. I have Identity 2 set up on my application. In Dev we use Entity Framework but in our test environment we update the database using SQL scripts, due to DBA policies.

I need to initially seed an Admin user the first time the application runs so that they can then add new users. Access to the app needs to be controlled. In Dev we use the seed method.

For our test environment I need to be able to seed the users, but because the password is saved to the database in an encrypted format, I'm not too sure how to handle this. From what I understand is that Identity 2 generates a seed every time the application runs for the first time and this seed is used to encrypt passwords.

Has anyone got a good solution for this?

have you considered using the Application_Start method of Global.asax.cs? You can create a method of your own and call it on the Application_Start() to check if there is a certain user in the database, if not, create the role and user you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM