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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM