I'm trying to build a project using onion architecture (just a "Northwind"ish type app to get more up to speed with .NET Core). I also want to get a better grasp on Onion Architecture principals. I understand it's not a one-size fits all solution, but I want to try to utilize most of the principals in this sample app.
I'm using EF Core and generating my data layer with the dotnet ef dbcontext scaffold
command. My thought is, I will maintain the database (via a VS Database project) and regenerate these files each time - so they wouldn't be touched by hand ever.
It seems that most of these entities could also act as domain entities.
My project structure would look something like this:
- Eastwind.sln
- Core
- Eastwind.Domain
- Interfaces\
- Entities\ - (location of generated POCO entities from EF)
- Extensions\
- Eastwind.Domain
- Outer
- Eastwind.Data - (location of dbcontext & EF config associating entities to datastore)
- Eastwind.Services
- Eastwind.WebApi
- Client (WebApi clients)
- Eastwind.Client.Web
- Eastwind.Client.Wpf
- Core
My questions are:
- Does it make sense to generate the entities (POCO classes) in the core/domain layer and keep the EF Configuration (fluent config code) and DbContext in a separate data layer that's outside of the Core?
- Does someone know of a good sample project that really utilizes the onion principals well? I've seen a few and they're questionable at best.
- Any other notes (or critiques) on issues in my structure relating to onion?
My thought is the data layer should sit outside the core still and rely on the entities on the lower layers (core). This seems onion'y to me still, but I haven't really seen anyone structure a project this way.
EDIT:
The Client projects are arguably insignificant to this question, as they will not utilize any of these libraries directly.
I am going to transform any input or output from the API to DTOs in order to keep them specific to the calls - combining and/or simplifying the data to keep them light weight and prevent the need for multiple round-trips as much as possible.
I MIGHT put the DTOs in a separate library to at least share those objects with the WPF Client project, but the Web Client project is using Angular so they will need to be redefined there.