https://stackoverflow.com/questions/45892312/how-to-add-an-implementation-of-idesigntimedbcontextfactorydatacontext-to-th
搞不明白2.0里這個報錯,討厭的Migration!
如果用了初始化數據。。。要分開run。好像是這么回事。。順序亂了
var host = BuildWebHost(args);
using (var scope = host.Services.CreateScope())
{
var services = scope.ServiceProvider;
try
{
InitializeDatabase(services ) ;
}
catch (Exception ex)
{
var logger = services.GetRequiredService<ILogger<Program>>();
logger.LogError(ex, "An error occurred seeding the DB.");
}
}
host.Run();