Skip to content

Instantly share code, notes, and snippets.

@scottsauber
Created October 12, 2018 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottsauber/18627771c15d0fe00a3365134ab1ce2b to your computer and use it in GitHub Desktop.
Save scottsauber/18627771c15d0fe00a3365134ab1ce2b to your computer and use it in GitHub Desktop.
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Run();
}
public static IWebHost CreateWebHostBuilder(string[] args)
{
var hostBuilder = WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
var host = hostBuilder.Build();
using (var scope = host.Services.CreateScope())
{
var dbContext = scope.ServiceProvider.GetService<ApplicationDbContext>();
dbContext.Database.EnsureCreated();
dbContext.Add(new IdentityRole
{
Name = "Test",
NormalizedName = "TEST"
});
dbContext.SaveChanges();
}
return host;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment