Update for build & deploy process

This commit is contained in:
Khajonpot
2020-02-20 21:26:40 +07:00
parent 8b98125e49
commit 815f38a289
5 changed files with 36 additions and 9 deletions

View File

@@ -67,4 +67,21 @@ namespace TestAPI01.Seed
return Path.Combine(currentDir, filePath);
}
}
public class MigrationData
{
public static void EnsureMigration(IServiceProvider serviceProvider)
{
Console.WriteLine("Migrate database...");
using (var scope = serviceProvider.GetRequiredService<IServiceScopeFactory>().CreateScope())
{
var context = scope.ServiceProvider.GetService<DataContext>();
context.Database.Migrate();
}
Console.WriteLine("Done.");
Console.WriteLine();
}
}
}