C
C#•12mo ago
fasadin

Clean architecture, how to register dbcontext

So in Presentation layer that's where API (controller) will be. Also that's an entry point for application. As this is entry of application, it has to do registrations of all services How to register Infrastructure layer? It has implementation of interfaces and dbcontext Somehow I have feeling that Presentation should know nothing about Infrastructure layer yet there are implementation of interfaces that are inside of Application
21 Replies
Joschi
Joschi•12mo ago
Expose an extension method on IServiceCollection from your other layers that does the registering.
fasadin
fasadinOP•12mo ago
but then I have to reference Infrastructure Layer to Presentation
Joschi
Joschi•12mo ago
But isn't that the way it works in CLEAN, that the outer layers reference the inner ones? Everything you don't want other layers to know about should be internal instead of public
fasadin
fasadinOP•12mo ago
Infrastructure and Presentation are on the same level, there is no outer nor inner in this case
Joschi
Joschi•12mo ago
Ohh you are right, never really worked with CLEAN. Then I'm not sure.
fasadin
fasadinOP•12mo ago
I am also not sure 😄 I don't think it's possible but it feels strange that it has to know only because of registering services it does not sounds clean
Batuhan
Batuhan•12mo ago
u can take this project as a base https://github.com/jasontaylordev/CleanArchitecture
GitHub
GitHub - jasontaylordev/CleanArchitecture: Clean Architecture Solut...
Clean Architecture Solution Template for ASP.NET Core - GitHub - jasontaylordev/CleanArchitecture: Clean Architecture Solution Template for ASP.NET Core
Batuhan
Batuhan•12mo ago
I hope every answer that you looking for is in that
Joschi
Joschi•12mo ago
Software Engineering Stack Exchange
What is the responsibility of Infrastructure layer in a clean archi...
I am trying to follow Clean Architecture by Uncle Bob. I have 3 layers: Core (Hosts business logic, and is the central layer) Application (Host application usecases, and is directly above the core)
Joschi
Joschi•12mo ago
That so question seems to be facing the same problem In the end I guess if you find that your frontend depends on something from the architecture layer, that particular logic shouldn't be in the frontend
fasadin
fasadinOP•12mo ago
https://github.com/jasontaylordev/CleanArchitecture/blob/main/src/Application/Application.csproj this has reference to entity framework in application, which is I think oposite of what clean architecture wants to achieve
GitHub
CleanArchitecture/src/Application/Application.csproj at main · jaso...
Clean Architecture Solution Template for ASP.NET Core - jasontaylordev/CleanArchitecture
fasadin
fasadinOP•12mo ago
ok, where is there answer to my question?
Anu6is
Anu6is•12mo ago
The WebUI contains Controllers and Views. It depends on the Infrastructure only in order to inject Infrastructure’s implementations within the Application project at startup time.
it's also shown in the diagram
fasadin
fasadinOP•12mo ago
It depends on the Infrastructure only in order to inject Infrastructure’s implementations
Yes, but that's does not seem clean that does not answer my hasitation
Somehow I have feeling that Presentation should know nothing about Infrastructure layer, yet there are implementation of interfaces that are inside of Application
if it "just" need information from Infrastructure layer to register stuff, why not have this somewhere else? in more "outer" layer (registration of services)
Anu6is
Anu6is•12mo ago
sometimes persons add a separate persistence layer
fasadin
fasadinOP•12mo ago
it would have to be entry point, but that's not easy as presentation layer it's most logical to be entry point
jcotton42
jcotton42•12mo ago
Just gonna drop this here $vsa
MODiX
MODiX•12mo ago
dotnet
YouTube
Vertical Slice Architecture: How Does it Compare to Clean Architect...
Is Vertical Slice Architecture the next big thing or just as cool new kid? Enterprise software development requires you to choose the right architecture. This session with Luke Parker will provide a realistic dive into Vertical Slice Architecture (VSA) with .NET; showcasing the potential shift from Clean Architecture (CA) to VSA. You will lear...
Derek Comartin
CodeOpinion
Restructuring to a Vertical Slice Architecture
What is Vertical Slice Architecture? It's about focusing and organizing code by features and capabilities, not technical concerns!
jcotton42
jcotton42•12mo ago
owo
fasadin
fasadinOP•12mo ago
thanks 🙂
Want results from more Discord servers?
Add your server