Reputation: 83
InvalidOperationException: Unable to resolve service for type 'AirlineManagement.Repository.UnitOfWork' while attempting to activate 'AirlineManagement.Controllers.StudentsController'.
What is that meaning exactly and how can i solved it??
For more info https://github.com/dotnet/core/issues/660
Upvotes: 0
Views: 893
Reputation: 15571
This means your DI container is trying to construct a StudentsController, and it cannot seem to find a registration for your UnitOfWork class (or any of its dependencies).
Make sure the UnitOfWork class (or better: the interface it implements) is registered in your DI of choice, along with all other referenced interfaces/classes.
EDIT: After looking at your code, you're missing a registration for the AirlineContext. Furthermore, you're newing stuff (the AirlineRepository in UnitOfWork) while you're using DI.
I can't help but get the feeling you haven't completely understood this yet...
Upvotes: 1