标签:get strong nec 调用 cti tor dsc context ibm
目录
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))。
标签:get strong nec 调用 cti tor dsc context ibm
原文地址:https://www.cnblogs.com/JerryMouseLi/p/11052009.html