I have this structure for the context of DbContext
dependency injection.
Domain project
- Entities
BusinessLogic project
- Feature
Infrastructure
- DbContext is here
API Project
- Controllers
Question is should the infrastructure project have reference to domain project to add the entities to DbContext
? Can the infrastracture layer pass through 1 layer below to access domain layer?
2
Answers
This is a very philosophical question, I think that the infrastructure layer can depend on the domain layer, but not vice versa (in a pure architecture, logic should not depend on the infrastructure).
But I would also add that it is possible to duplicate entities for the infrastructure layer, because If this is not done, then domain models may have infrastructure attributes (or something else).
But you need to look at the situation, sometimes adding extra entities is an overhead
IMHO
You can take a look to the eShop Reference Application repo : eShop GitHub repo
At the Ordering service you can see how they deal with the infrastructure dependency!