Revising the DbSeeder

Now that our ApplicationUser model class is inheriting the IdentityUser base class, we most likely broke the seeding mechanism we set up back in Chapter 4, Data Model with Entity Framework Core. However, it's not a big deal; we can take the chance to create some sample roles, since we can now make good use of them.

The first thing we need to do is to provide our DbSeeder class with a UserManager and a RoleManager, as they are the required Microsoft.AspNetCore.Identity handler classes to properly work with users and roles. We can inject them using DI within the service scope we defined in the Startup.cs file back in Chapter 4, Data Model with Entity Framework Core, and then pass them to the DbSeed.Seed() method, just ...

Get ASP.NET Core 2 and Angular 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.