.net identity seed users and roles

C#
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();
}
Source

Also in C#: