0

I have a solution with the following project:

Core/Services/Services Interfaces/Infrastructure/Web UI

In the Infrastructure project I have the following folders: -Data -IoC -Logging

The data folder in the Infrastructure project contains a DbContext class, repos and a UoW class... The services project needs to reference the Infrastructure to access the data and the Infrastructure needs to reference the services project so the IoC container can resolve its dependencies..That creates a circular dependency..

Whats a good way to solve this? Should there be a Infrastructure project and should the data and IoC be part of it?

tereško
  • 58,060
  • 25
  • 98
  • 150
Alex808
  • 109
  • 9

1 Answers1

1

IoC is not infrastructure, it's just a way of stitching your program entities together - none of your business logic, infrastructure or services should have access to your IoC container. The container should only be used at the composition root. This tends to be wherever your application is initialized. In a web application, you would register everything with your IoC container upon startup (in the web project) then resolve instances of a controller from the container when requested. The rest of your code remains agnostic to the container.

Community
  • 1
  • 1
Alex
  • 7,639
  • 3
  • 45
  • 58