I\'ve found this answer but it doesn\'t seem to fit in my ASP Net Core project.
Things I am trying to understand:
In addition to Temi's detailed answer, remember to replace
services.AddDefaultIdentity()
.AddEntityFrameworkStores();
With
services.AddIdentity().AddEntityFrameworkStores();
Also, make sure that the types specified in AddIdentity<>
is the same as the types called in serviceProvider.GetRequiredService<>
For the above, our types called in serviceProvider.GetRequiredService<>
in Configure.cs would be
var roleManager = serviceProvider.GetRequiredService>();
var userManager = serviceProvider.GetRequiredService>();
Another important thing to note is that since CreateRoles(IServiceProvider)
(from Temi's answer) is an async method, to call it in Configure
method (which return void), you can use
CreateRoles(serviceProviderInstance).Wait();
Hope this helps.