Skip to content

Instantly share code, notes, and snippets.

@Rudyzio
Created April 12, 2019 21:54
Show Gist options
  • Save Rudyzio/5aabb8a6f95e6114e7dbacc80714fa71 to your computer and use it in GitHub Desktop.
Save Rudyzio/5aabb8a6f95e6114e7dbacc80714fa71 to your computer and use it in GitHub Desktop.
public class Program
{
public static void Main(string[] args)
{
var host = CreateWebHostBuilder(args).Build();
using (var scope = host.Services.CreateScope())
{
var services = scope.ServiceProvider;
try
{
var context = services.GetRequiredService<ApplicationDbContext>();
DataSeeder.Initialize(context);
} catch (Exception)
{
Console.WriteLine("An error occurred while seeding the database.");
}
}
host.Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args).UseStartup<Startup>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment