0

I have an ASP.NET Core solution consisting of 4 projects: Domain for pure business rules, Application for app specific operations, Infrastructure for data access and Web for controllers, razor pages and other asp.net stuff. The dependency order between them is as follows:

Application >>> Domain

Infrastructure >>> Application

Web >>> Application

I'm using Autofac modules for DI. To register dependencies I have to reference the Infrastructure from Web project, which is something I don't feel good about it. Another idea to load the Infrastructure in the program is to introduce another project referencing all other projects solely to register the dependencies and bootstrap the app. Is the resistance to adding a reference to Infrastructure from Web an overkill? Or I should choose the second way and add another project to boot the app. If second How to add it. because the registration is inside the Startup class which belongs to Web project.

ahamid555
  • 173
  • 1
  • 15
  • 1
    Without describing what logic and code resides in `Infrastructure`, `Web`, and `Application` and what their functions are, it's impossible to comment on this. Still, [this q/a](https://stackoverflow.com/questions/9501604/ioc-di-why-do-i-have-to-reference-all-layers-assemblies-in-applications-entry) might give you some hints. – Steven Oct 29 '21 at 11:25
  • @Steven I updated my question if it helps. The entry point is the Web project and I have to add references to all other projects including Infrastructure. But that would be violation of clean architecture rules. Other than introducing new project for entry point, Is there any other solution to register Infrastructure without referencing it? – ahamid555 Oct 29 '21 at 13:19
  • Hi ahamid555, which "clean architecture rules" are you referring to? – Steven Oct 29 '21 at 13:39
  • @Steven "The overriding rule that makes this architecture work is The Dependency Rule. This rule says that source code dependencies can only point inwards." Web and UI should not depend on Database. Of course dependency is at the reference level, that's why I asked is it overkill or not. – ahamid555 Oct 29 '21 at 13:50
  • The reference that I gave earlier gives answers to your question. – Steven Oct 29 '21 at 13:52

0 Answers0