skip to Main Content

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


  1. 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

    Login or Signup to reply.
  2. 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!
    Ordering projects image

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search