Skip to content

Instantly share code, notes, and snippets.

@ntakouris
Created July 23, 2019 08:28
Show Gist options
  • Save ntakouris/57942ffc49fa43c54964499902ca35fb to your computer and use it in GitHub Desktop.
Save ntakouris/57942ffc49fa43c54964499902ca35fb to your computer and use it in GitHub Desktop.
using (var serviceScope = host.Services.CreateScope())
{
var roleManager = serviceScope.ServiceProvider.GetRequiredService<RoleManager<IdentityRole>>();
if (!await roleManager.RoleExistsAsync("Admin"))
{
var adminRole = new IdentityRole("Admin");
await roleManager.CreateAsync(adminRole);
}
if (!await roleManager.RoleExistsAsync("Poster"))
{
var posterRole = new IdentityRole("Poster");
await roleManager.CreateAsync(posterRole);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment