---
title: Getting started with .NET Core
description: Getting started with .NET Core
---

import { Code } from '@astrojs/starlight/components';
import { Aside } from '@astrojs/starlight/components';

import installCode from 'install.sh?raw';
import healthQueryCode from 'health-query.cs?raw';
import programCode from 'program.cs?raw';

export const highlights = ['OpenHarbor.CQRS', 'OpenHarbor.CQRS.AspNetCore.Mvc', 'AddDefaultCommandDiscovery', 'AddDefaultQueryDiscovery', 'AddOpenHarborCommands', 'AddOpenHarborQueries', 'AddQuery', 'IQueryHandler'];

In this tutorial, we will create a simple health query within a brand-new .NET 8 Web API project using the Open Harbor CQRS framework.

### Setup

Let's get started by creating a brand-new project!
<Code code='dotnet new webapi -o OpenHarbor.Guide' lang='sh' title='.net cli' />

### Install the .NET package
Run the following commands to install the required packages:
<Code code={installCode} lang="sh" title='.net cli' />

### Creating our first query
We will create a simple health check endpoint to verify that our API is running:
<Code code={healthQueryCode} lang="csharp" title='Query/HealthQuery.cs' mark={highlights} />

<Aside type="caution">The current version of the framework requires registering at least one query for .NET MVC to function properly. This limitation will be resolved in a future update.</Aside>

### Preparing our program using MVC to bind our queries and commands

<Code code={programCode} lang="csharp" title='Program.cs' mark={highlights} />

`AddDefaultCommandDiscovery` and `AddDefaultQueryDiscovery` are the default implementations in the CQRS framework for discovering the commands and queries defined in your application. To learn more about how they work, you can check out their functionality <a href="https://git.openharbor.io/Open-Harbor/dotnet-cqrs/src/branch/main/OpenHarbor.CQRS/Discovery" target="_blank" rel="noopener noreferrer">here</a>.

`AddQuery` is used to register your query, allowing the framework to expose it automatically.

`AddOpenHarborCommands` and `AddOpenHarborQueries` dynamically generate controllers for your application, leveraging the MVC features of .NET

<Aside type="note">A future update will include support for Minimal APIs in .NET, providing an alternative to the current MVC-based implementation.</Aside>

### Reaping the rewards of our work!

Run the project and navigate to `/api/query/health` in your browser to see the result.

### What's next?

🎉 Congratulations! You've successfully created your first CQRS Web API with a simple health check query. In the next guide, we’ll explore adding a command and a query that interact with each other, showcasing the endless possibilities you can unlock with our CQRS framework. Let your imagination run wild!
