Why am I getting the error “Cannot instantiate implementation type” for my generic service?

前端 未结 4 2096
挽巷
挽巷 2021-02-12 09:12

I have a generic repository that I have been instantiating right in my WEB API Controller no problem for a while.

This is what my controller used to look like:



        
4条回答
  •  南笙
    南笙 (楼主)
    2021-02-12 10:11

    I'm an idiot. I had the Inteface for the implementation. I changed:

    services.AddScoped(typeof(IGenericService<>), typeof(IGenericService<>));
    

    to

    services.AddScoped(typeof(IGenericService<>), typeof(GenericService<>));
    

提交回复
热议问题