Introducing SSW Data Onion
Integrate Entity Framework into your Onion Architecture Enterprise Application
When building enterprise .net applications you should follow the Onion Architecture as outlined above. This domain model-centric approach encourages the development of maintainable solutions by integrating loosely coupled components via interfaces.
Adopting Onion architecture can lead to writing lots of extra code. SSW Data Onion makes this easy by generating an Entity Framework Code First implementation for persisting your Domain Entities.
In a nutshell
- SSW Data Onion contains 3 .tt templates that read domain classes from your appropriate domain assembly
- We generate a repository interface for each domain class.
- We generate a default EF Code first repository implementation for each domain class.
- The DbContext also needs to reference every class so we also generate that.
- We also have a set of core classes to support:
- Dependency injection of DBInitializers http://www.entityframeworktutorial.net/code-first/database-initialization-strategy-in-code-first.aspx
- Managing DbContext lifecycle in a unit of work pattern