Skip to content

Environment Setup

Terminal window
# Check version
dotnet --version
# Example output: 10.0.100
# Install (Windows)
winget install Microsoft.DotNet.SDK.10
# Install (macOS)
brew install --cask dotnet-sdk
# Install (Linux - Ubuntu)
sudo apt-get update && sudo apt-get install -y dotnet-sdk-10.0
  • .NET 10.0 SDK is automatically detected
  • Verify the SDK path in File -> Settings -> Build, Execution, Deployment -> Toolset and Build
  • Visual Studio 2022 version 17.12 or later recommended
  • Workloads: ”.NET desktop development” or “ASP.NET and web development”

Terminal window
# Clone the Functorium project
git clone https://github.com/hhko/Functorium.git
cd functorium
Terminal window
# Build the entire solution
dotnet build Functorium.slnx
# Run all tests
dotnet test --solution Functorium.slnx
Terminal window
# Run tests for Part 1 first chapter
dotnet test --project Docs.Site/src/content/docs/tutorials/cqrs-repository/Part1-Domain-Entity-Foundations/01-Entity-And-Identity/EntityAndIdentity.Tests.Unit
# Build/test the entire tutorial
dotnet build Docs.Site/src/content/docs/tutorials/cqrs-repository/cqrs-repository.slnx
dotnet test --solution Docs.Site/src/content/docs/tutorials/cqrs-repository/cqrs-repository.slnx

These are the default using statements used in the projects:

// Domain entities
using Functorium.Domains.Entities;
// Repository
using Functorium.Domains.Repositories;
// Query adapter
using Functorium.Applications.Queries;
// Usecase
using Functorium.Applications.Usecases;
// Specification
using Functorium.Domains.Specifications;

When using LanguageExt functional types:

using LanguageExt;
using LanguageExt.Common;
using static LanguageExt.Prelude;

Terminal window
# Run tests for a specific project
dotnet test --project Docs.Site/src/content/docs/tutorials/cqrs-repository/Part1-Domain-Entity-Foundations/01-Entity-And-Identity/EntityAndIdentity.Tests.Unit
# Run a specific test
dotnet test --filter "Create_ReturnsAggregate_WhenValid"
Terminal window
# From the solution root
dotnet test --solution Functorium.slnx

Each tutorial project follows this structure:

01-Entity-And-Identity/
├── EntityAndIdentity/ # Main project
│ ├── EntityAndIdentity.csproj # Project file
│ └── Domains/ # Domain classes
│ ├── Product.cs
│ └── ProductId.cs
└── EntityAndIdentity.Tests.Unit/ # Test project
├── EntityAndIdentity.Tests.Unit.csproj
├── xunit.runner.json
└── ProductTests.cs

Each project references the Functorium library. It is configured in the project file as follows:

<ItemGroup>
<ProjectReference Include="../../../../../../../../../Src/Functorium/Functorium.csproj" />
</ItemGroup>

Key CQRS-related types provided by Functorium:

NamespaceKey TypesPurpose
Functorium.Domains.EntitiesEntity<TId>, AggregateRoot<TId>, IEntityIdDomain entities
Functorium.Domains.RepositoriesIRepository<TAggregate, TId>Command-side Repository
Functorium.Applications.QueriesIQueryPort<TEntity, TDto>Query-side adapter
Functorium.Applications.UsecasesICommandRequest, IQueryRequestUsecase interfaces
Functorium.Applications.PersistenceIUnitOfWork, IUnitOfWorkTransactionPersistence

Terminal window
# Check PATH environment variable
echo $PATH
# On Windows, add the following path to system environment variables
# C:\Program Files\dotnet
  1. Restart the IDE
  2. Run dotnet restore
  3. Delete the .vs or .vscode folder and restart

Verify that the LanguageExt.Core package has been properly restored:

Terminal window
dotnet restore
dotnet build

Q1: Can I use an earlier version instead of .NET 10.0 SDK?

Section titled “Q1: Can I use an earlier version instead of .NET 10.0 SDK?”

A: The projects in this tutorial target .NET 10.0. Some LanguageExt and Functorium APIs may not be compatible with earlier versions, so installing the .NET 10.0 SDK is recommended.

Q2: Can I test individual projects without building the entire solution?

Section titled “Q2: Can I test individual projects without building the entire solution?”

A: Yes, running dotnet test from each chapter’s test project folder will build/test only that project. Building the entire solution is used to verify consistency across all projects.

Q3: What should I do if LanguageExt build errors occur?

Section titled “Q3: What should I do if LanguageExt build errors occur?”

A: First, restore packages with dotnet restore. If that doesn’t resolve it, delete the bin and obj folders and rebuild. Also verify that the LanguageExt.Core package downloads correctly from the NuGet source.


With the environment setup complete, it’s time to understand the overall structure of the CQRS pattern.

-> Chapter 0.3: CQRS Pattern Overview