Aneeq
Aneeq

Reputation: 416

Visual Studio Multi Project Solution Issue

I have this solution in VS 2017 which has multiple projects:

So well, my Web project references Infrastructure and the Infrastructure project references DataAccess as well as DomainModels projects. The solution is working fine.

However, if inside my Web project, if I try to access any of the entities from the DomainModels, I can easily access that without any errors, even though Web project doesn't have any reference to the DomainModels.

Can you please help me understand how this referencing of the project works? Is it because the web project has indirect reference to the DomainModels (Web -> Infrastructure -> DomainModels)?

Thanks.

Upvotes: 3

Views: 84

Answers (2)

w0051977
w0051977

Reputation: 15817

Please investigate the Onion architecture: https://social.technet.microsoft.com/wiki/contents/articles/36655.onion-architecture-in-asp-net-core-mvc.aspx

The Domain Model should not reference anything. In order to achieve this; you should investigate dependancy inversion. I asked a question recently about dependancy inversion here: Execute code in a class library when you do not have a reference to that class library

If you want to divorce the domain layer from the web then you could introduce a service layer.

Upvotes: 1

karthik kasubha
karthik kasubha

Reputation: 434

Indeed , as per your comments web will have reference to all other projects

When you compile , The Infrastructure will be having references dataaccess and domain model namespaces attached to it hence you are able to access the types or namespaces present in dataaccess and domain models from web since you are refering Infrastructure from web .

Upvotes: 1

Related Questions