海南英才招聘,降临异世的死神,好乐宝网站
目录
system.invalidoperationexception: unable to resolve service for type 'ibms.infrastruct.uow.unitofwork' while attempting to activate 'ibms.webapi.controllers.valuecontroller'.
出错图片如下:
system.invalidoperationexception: unable to resolve service for type 'ibms.infrastruct.context.ipboxcontext' while attempting to activate 'ibms.infrastruct.uow.unitofwork'.
出错图片如下:
在startup.cs中的configureservices方法中进行依赖注入
services.adddbcontext<iipboxcontext, ipboxcontext>(options => options.usemysql(configuration.getconnectionstring("mysqlconnection"))); services.addscoped<iipboxrepository, ipboxrepository>(); services.addscoped(typeof(unitofwork));//注入工作单元 services.addscoped(typeof(ipboxcontext));
注意:ipboxcontext进行adddbcontext注入数据上下文之后,仍需要注入services.addscoped(typeof(ipboxcontext))。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
asp.net搭建博客,使用BlogEngine.NET+MySql搭建博客
网友评论