I have a ASP.NET Core 3.1 MVC application using ASP Identity for Authentication and Authorization that I created using Visual Studio 2019
I'm using the Northwind SQL Server sample database.
So in my app I created a Migration for the ASP.NET Core Identity tables and then ran the Update-Database command which created these ASP.NET Core Identity tables in my database.
[Northwind].[dbo].[AspNetRoleClaims]
[Northwind].[dbo].[AspNetRoles]
[Northwind].[dbo].[AspNetUserClaims]
[Northwind].[dbo].[AspNetUserLogins]
[Northwind].[dbo].[AspNetUserRoles]
[Northwind].[dbo].[AspNetUsers]
[Northwind].[dbo].[AspNetUserTokens]
I already know how to create new roles and users by using a form on one of my views.
Then on another view I am able to assign roles to a user.
Now I'm trying to learn how to seed users into the ASP.NET Core Identity tables mentioned above.
On the internet I've searched "asp.net core identity seeding data".
I found lots of good examples on seeding data into a regular table. I already know how to do that.
But I didn't really find a good example on seeding data users and roles into the ASP.NET Core Identity tables.
The difference I have seen is that when seeding data into ASP.NET Core Identity tables, I have to hash the password and other few columns.
Does anyone have a reference to a good article or video on seeding data into ASP.Core Identity tables in a ASP.NET Core 3.0 MVC or higher application?
In your example you created user with this line.
var defaultUser = new OblakSystemUser
I created a ASP.NET Core 5 MVC example where I seeded 2 users and it worked great
The first line of the two snippets for the 2 users looked like this:
var appUser1 = new AppUser {
// the user properties go here
}
var appUser2 = new AppUser {
// the user properties go here
}
If I needed to seed a hundred users would I just you a loop to create the AppUser objects instead of hard coding them like the sample above?