Created
December 28, 2023 04:09
-
-
Save danielmackay/edf58c4987bc5a188214f4e348fec840 to your computer and use it in GitHub Desktop.
Apply Migrations Extension Method
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 class MigrationExtensions | |
{ | |
public static void ApplyMigrations(this IApplicationBuilder app) | |
{ | |
using IServiceScope scope = app.ApplicationServices.CreateScope(); | |
using ApplicationDbContext dbContext = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>(); | |
dbContext.Database.Migrate(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment