Last active
December 8, 2017 15:42
-
-
Save nshathish/a008ca271753725555f78c6410cbb47a to your computer and use it in GitHub Desktop.
asp.net core program.cs with seed data method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
var host = BuildWebHost(args); | |
// RunSeedMethods(host); | |
host.Run(); | |
} | |
public static IWebHost BuildWebHost(string[] args) => | |
WebHost.CreateDefaultBuilder(args) | |
.UseApplicationInsights() | |
.UseStartup<Startup>() | |
.Build(); | |
// ReSharper disable once UnusedMember.Local | |
private static void RunSeedMethods(IWebHost host) | |
{ | |
using (var scope = host.Services.CreateScope()) | |
{ | |
var services = scope.ServiceProvider; | |
try | |
{ | |
var userManager = services.GetRequiredService<UserManager<ApplicationUser>>(); | |
var roleManager = services.GetRequiredService<RoleManager<ApplicationRole>>(); | |
// DatabaseIdentityInitializer.Init(userManager, roleManager).Wait(); | |
DatabaseIdentityInitializer.CreateDeveloperAccount(userManager, roleManager).Wait(); | |
} | |
catch (Exception e) | |
{ | |
Console.WriteLine(e); | |
throw; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment