I am trying to seed my database and add roles to my ASP.NET Core Web Application. In the tutorial I am following, it advised to add the following to the Configure() method:
app.UseAuthentication();
MyIdentityDataInitializer.SeedData(userManager, roleManager);
I had no issues with the first line, but with the second, I am getting an error saying userManager and roleManager doesn't exist which makes sense because if i were using .NET 5 my configure method would've looked like this and been fine:
public void Configure(IApplicationBuilder app,
IHostingEnvironment env,
UserManager<MyIdentityUser> userManager,
RoleManager<MyIdentityRole> roleManager)
{
...
app.UseAuthentication();
MyIdentityDataInitializer.SeedData(userManager, roleManager);
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
But in .NET 6 I'm not sure how to.
Can someone advise on this please?