Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin user and role in the seed() of ApplicationDbInitializer is not executed #4

Open
rjiang9 opened this issue Oct 4, 2016 · 4 comments

Comments

@rjiang9
Copy link

rjiang9 commented Oct 4, 2016

Application runs well but did not see the seeded Admin 'User' and 'Role', please help.
Thanks,
Jwndev

@xivSolutions
Copy link
Contributor

What version of ASP.NET and Identity are you using? This post is a little long in the tooth now, and was written against Identity 2.0 before it was included as a template in VS. THings may have changed a little since then.

@rjiang9
Copy link
Author

rjiang9 commented Oct 4, 2016

Thank you for your quick response. I am using

Asp.net version: 4.5
Identity Core2.2.1
Visual Studio 2013
SQL server 2014.

Basically I just download it as zip from Github. Then
Open the solution in VS,
update the packages,
setup default connection string with SQL server in Web.config
Create a new empty DB in SQL server

And then run the app. It works good and I can register users. But the DB tables were not created until I registered the first new user (Tables were not created when the app starts first).

By the way, this one created by John was just working fine with seeding the admin data:
https://github.com/TypecastException/AspNet-Identity-2-Extending-Users-And-Roles

I tried to compare the the files but I did not find where the key is. You help or directions are appreciated very much.

Thanks,
Ray

@xivSolutions
Copy link
Contributor

Ooops. Didn;t mean to close that! Btw, I am John.

Do me a favor, and see what happens if you change the password for the users to include a non-alphanumeric character - like "Password1!"

I seem to recall they may have tightened up the default password requirements. If you are using Identity 2.2.1 this may be what is preventing the user from being created?

I've been away from this project for a while, but I'll try to take a lok in the next few days.

@rjiang9
Copy link
Author

rjiang9 commented Oct 5, 2016

Hi John,

It is working for me now. Your package has no issues at all and is working on the most recent Identity version just well. I think I found why I had this issue. There is a concept about at what point the application db seed() code got executed.

When I launched the app, http://localhost through IIS or http://localhost:6208 through VS, the DB tables were not created. Navigating the default menu items (Application Name, Home, Contact, Register, Login) does NOT trigger the seed() to be executed either. It only happens when I click login and use admin user email and password set in the seed() code, the DB tables are created and login is successful.

I think 'code triggered when the app/project starts' was a little confusing to me.

I want to say thank you again for your packages and the great series of articles on your website:

http://johnatten.com

And thank you for your time and help offer.

Regards,
Ray

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants