Created
April 24, 2018 15:02
-
-
Save shawnweisfeld/d22c56ba31bd45e9e4a78b6561dd96f5 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 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