So, my question is specific but architectural in nature but definitely answerable with a technical answer so I hope stackoverflow rather than stackexchange is the right place.
I have a "Clean Architecture" setup for a project. So asp.net core 3.1 razor pages UI which talks to the backend via a Restful web API. Thin asp.net core 3.1 API controllers then talk to an App layer class library project which employs CQRS to either fire stuff into a Domain core or accesses a Data Access Layer for queries. All pretty standard.
My dependencies are setup like so:
- UI has NO dependencies on any other layer
- API layer has a dependency on the App layer
- App layer has a dependency on the Domain layer
- Domain layer has no dependencies on any other layer
- Data Access layer, another .net core class library, has dependency on App Layer and Domain layer
Dependencies are therefor inverted correctly with the App and Domain layers exposing Data Access interfaces which the Data Access Layer implements to provide those services. Again all pretty standard.
So my question is this:
I am using my Api startup class to register general class dependencies for the API and App layer, via basic extension method call which the App layer "passes on" by registering any service for the Domain layer etc. but in this setup...
Q: how do you register services for the Data Access Layer?
I have been allowing a dependency on the Data Access Layer from the UI and calling an extension method from there to register the services but that just feels wrong! Why on earth should the UI be bothered about stuff the Data Access Layer does, even though they both live in the infrastructure ring.
But I also don't want the Api layer having a dependency on DAL as again that is not it's concern. It seems the DAL should not really be any layers concern to me.
My thinking has turned to the question of registering services in a class library, which has no startup class so
Q: Is this even possible?
Q: Am I missing some basic concept here?
Thanks in advance