Unable to create an object of type 'ApplicationDbContext'.

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();

posted @ 2018-04-09 15:14  elegydance  阅读(2223)  评论(0编辑  收藏  举报