Created
October 12, 2018 19:24
-
-
Save scottsauber/18627771c15d0fe00a3365134ab1ce2b to your computer and use it in GitHub Desktop.
This file contains 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) | |
{ | |
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