Do you know the layers of the onion architecture?Last updated by Piers Sinclair [SSW] over 2 years ago.See history
Figure: The layers of the onion architecture
This should be the big meaty part of the application where the domain logic resides.
In the very centre, we see the Domain Model, which represents the state and behaviour combination that models truth for the organization and is only coupled to itself.
The first layer around the Domain Model is typically where we find interfaces that provide object saving and retrieving behaviour. The object saving behaviour is not in the application core, however, because it typically involves a database. Only the interface is in the application core. The actual implementation is a dependency which is injected.
Business logic is also exposed via interfaces to provide decoupling of business logic. Examples of where this is useful include substituting a FacebookNotificationService for an EmailNotificationService or a FedExShippingCalculator for a DHLShippingCalculator
The outer layer is reserved for things that change often. E.g. UI and the other applications that consume the Application Core. This includes the MVC project. Any interface dependencies in factories, services, repositories, etc, are injected into the domain by the controller. This means any constructor-injected interfaces in domain classes are resolved automatically by the IoC container.
Dependencies are implementations of interfaces defined in Repository and Business Logic Interfaces and Domain. These classes are specific implementations and can be coupled to a particular method of data access, or specific service technology. e.g. this is where the EF DbContext is implemented, as well as things like logging, email sending, etc.
These dependencies are injected into the application core.
Because the Application core only relies on abstractions of the dependencies, it is easy to update them.
To help make this process pain free, we've developed the SSW Data Onion to get you going and take away the boilerplate code you would normally need to write. Check out this cool video to see how it works:
Further Reading: Do You Use a Dependency Injection Centric Architecture?