When it is necessary for an entity/object to know about other objects, or they largely depend on interfaces where service methods are defined, it is called tight coupling. Whereas in loose coupling, the dependency between objects is very little and there is proper separation of concerns among interfaces. As a result, the framework is more stable and its maintainability is very easy.
ONION ARCHITECTURE OVERVIEW

As shown in the above image, the Domain Model is the core and it consists of POCO entries. The brown layer has service interfaces. The green layer is the layer of implementation or the Infrastructure layer. All the service methods, repositories, and dependency injections are implemented in this layer. The blue layer has User Interfaces and the testing.
USING THE CODE

The CORE
The Core looks like the following.

There is a class library project in the Core folder called as interfaces for both Services and Repositories. There is a Model with an auto generated file (.tt file) that contains POCO entities.
The INFRASTRUCTURE
This folder is composed of the integral part of the application. There are multiple projects in this folder. The first project is the class library project and there is .edmx file in its first folder named as data. It also contains the ".tt" file and the context classes.
The second project in this folder is dependency injection. In this project, there are two classes- each for the Service Module and the Repository module.
The third project in this folder is the Error logging project. It helps in identifying exceptions or errors in the database. In the infrastructure project, those operations are performed that are linked to the outside application, such as operations related to access of file systems, database operations, access of outside service. The following activities need to be performed while creating the Infrastructure project.
- Create a class for database context.
- Repository class implementation.
- Create a class for database initializer.
The WEB Project
Create an MVC application that will make use of the infrastructure project and the core project. Following references need to be added in the Web project:
- Add a reference to the infrastructure project.
- Add a reference to the core project.
- Add a reference to the package of Entity framework.
DEPENDENCIES

The Web project is dependent on other two projects i.e. the Infrastructure and the Core, as shown on the diagram above. Infrastructure project is dependent on the Core project and the Core Project is independent of every other project.
The main features of Onion Architecture include
- The main application is made as an independent model.
- Interface is defined by the inner layer while the implementation is done by the outer layer.
- As the name suggests, the direction of coupling is at the center.

Bikesh SrivastavaPosted Nov 25, 2016, 5:10 AM
Very nice article ,Keep it up ,good job.