Answers for ".net identity seed users and roles"

C#
0

.net identity seed users and roles

public static void Main(string[] args)
{
    var host = BuildWebHost(args);

    using (var scope = host.Services.CreateScope())
    {
        var serviceProvider = scope.ServiceProvider;
        try
        {
            var userManager = serviceProvider.
GetRequiredService<UserManager<MyIdentityUser>>();

            var roleManager = serviceProvider.
GetRequiredService<RoleManager<MyIdentityRole>>();

            MyIdentityDataInitializer.SeedData
(userManager, roleManager);
          	// Add Users and Roles
        }
        catch
        {
                   
        }
    }
    host.Run();
}
Posted by: Guest on March-08-2020

Code answers related to ".net identity seed users and roles"

C# Answers by Framework

Browse Popular Code Answers by Language