Skip to content

Instantly share code, notes, and snippets.

@GistCF
Last active February 22, 2024 00:07
Show Gist options
  • Save GistCF/d5051f7b69d7b995b65d4d34325f43a9 to your computer and use it in GitHub Desktop.
Save GistCF/d5051f7b69d7b995b65d4d34325f43a9 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();
}
}
@devsuperman
Copy link

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment