A .net core Micro service Template using DDD

I was reading an article on Domain Driven Design (DDD) in a micro-service application which contained good example code that I wanted to use for one of my own projects. As I started creating the projects setup I thought; I don’t want to repeat this for every micro service I create, this should be a template. So I created one that you are free to use.

Targets: C#, .net core 3.1

Installation & Usage


Download the template file, open up your favourite shell and we are ready to install

template files

You can download a zip file or a nuget package. If you go with the zip file, unzip it in a location where you want to keep your templates.

In your shell:

To list all installed templates

$ dotnet new --list

To install the tempalte:

$ dotnet new -i ./microservice


$ dotnet new micro -n FooBar

The template “Microservice domain driven design template using mediatr” was created successfully.

$ cd FooBar/ && ls
FooBar.API/ FooBar.Domain/ FooBar.Infrastructure/ FooBar.UnitTest/

if you want to add a new solution file:

$ dotnet new sln
The template "Solution File" was created successfully.
$ ls
FooBar.API/ FooBar.Domain/ FooBar.Infrastructure/ FooBar.sln FooBar.UnitTest/

Add all project to a solution

$ for d in *; do dotnet sln add $d; done
Project `FooBar.API\FooBar.API.csproj` added to the solution.
Project `FooBar.Domain\FooBar.Domain.csproj` added to the solution.
Project `FooBar.Infrastructure\FooBar.Infrastructure.csproj` added to the solution.
Project `FooBar.UnitTest\FooBar.UnitTests.csproj` added to the solution.

Open the solution in your favourit IDE

open solution in your favorite C# IDE, note that the template has run dotnet restore and all project references are intact. sweet isn’t it?

For more information on templating

The code used for the domain is from the following article

Clone it on GitHub

Feel free to clone this on GitHub

Pin It on Pinterest