I have three projects: WebAPI, Services and Repository.
WebAPI
has a reference to Services
and Services
has reference to Repository
.
Now I need to add a Unity Container for Services
and Repositories
but in WebAPI
it's doesn't allow to add a reference to Repository
, WebAPI
has reference just for Services
.
I know how to configure the unity
for Services
, but how to this also for Repository
How can I change this in order to obtain the desired design ?
My suggestion is to simply add another project - name it something like "Infrastructure". This project can then have sole responsibility for registering things with IoC - so this project would need to reference every project which contains anything that needs registering, and it could be invoked by the WebAPI project.
This way the WebApi project doesn't need to directly know about anything in the Respository; it only knows how to get an IoC container which can then be used by everything.