Created
June 12, 2019 07:10
-
-
Save wullemsb/45f31bb7cbd04b9645af35813762e0d9 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
if (!Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT").Equals("local", StringComparison.OrdinalIgnoreCase)) | |
{ | |
var serviceProvider = services.BuildServiceProvider(); | |
using (var ctx = serviceProvider.GetService<SampleContext>()) | |
{ | |
var pendingMigrations = ctx.Database.GetPendingMigrations().ToList(); | |
if (pendingMigrations.Any()) | |
{ | |
throw new Exception( | |
$@"Please contact the administrator. The following database migrations are pending: | |
{string.Join(Environment.NewLine, pendingMigrations)} | |
"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment