Skip to content

Instantly share code, notes, and snippets.

@caseyspaulding
Forked from GistCF/run a db migrate from C#
Created December 27, 2022 21:26
Show Gist options
  • Save caseyspaulding/5e621fe3ab762d08d9ddc8c711a824a8 to your computer and use it in GitHub Desktop.
Save caseyspaulding/5e621fe3ab762d08d9ddc8c711a824a8 to your computer and use it in GitHub Desktop.
public static class DataHelper
{
public static async Task ManageDataAsync(IServiceProvider svcProvider)
{
//Service: An instance of db context
var dbContextSvc = svcProvider.GetRequiredService<ApplicationDbContext>();
//Migration: This is the programmatic equivalent to Update-Database
await dbContextSvc.Database.MigrateAsync();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment