Skip to content

Instantly share code, notes, and snippets.

@shawnweisfeld
Created April 24, 2018 15:02
Show Gist options
  • Save shawnweisfeld/d22c56ba31bd45e9e4a78b6561dd96f5 to your computer and use it in GitHub Desktop.
Save shawnweisfeld/d22c56ba31bd45e9e4a78b6561dd96f5 to your computer and use it in GitHub Desktop.
public static void Main(string[] args)
{
var host = BuildWebHost(args);
using (var scope = host.Services.CreateScope())
{
var services = scope.ServiceProvider;
try
{
using (var context = services.GetService<MovieContext>())
{
context.Database.Migrate();
}
}
catch (Exception ex)
{
var logger = services.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "An error occurred seeding the DB.");
}
}
host.Run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment