Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio - DDD Modules and Onion

I am developing a C# application following DDD and Onion Architecture concepts, but I cannot realize how to separate the code:

  1. I want it separated by modules -bounded contexts- (i.e. Sales; Suppliers; Clients)
  2. and I want it separated by layers (i.e. Core; Services)

It comes to mind doing the following: one project per layer and one folder (with an unique namespace) per module. For example:

Project Core

  • Folder Sales
  • Folder Suppliers
  • Folder Clients

Project Services

  • Folder Sales
  • Folder Suppliers
  • Folder Clients

However, I think I could do it reverse: one project per module and one folder per layer.

I dont know if there are more approaches.

Thank you.

like image 544
Franco Avatar asked Feb 06 '26 10:02

Franco


1 Answers

One approach that works well in VS is the following:

  • Create one project per module. This is a natural approach, because you have explicit dependencies between projects.
  • Use Solution Folders to group the projects into layers. You can prefix the layer with a number, so that it shows up in order within visual studio. Note that solution folders are virtual, i.e. not visible in the file system, but that is usually not a concern.
like image 117
theDmi Avatar answered Feb 09 '26 01:02

theDmi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!