aspnetcore: seed identity database code example

Example: .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();
}