-
Notifications
You must be signed in to change notification settings - Fork 14
Tutorial 02 02 Creating a Basic Solution

Using the harmonycore template is a quick way to create a basic development environment for a Harmony Core service that you can easily customize to meet your exact needs.
In the following steps, you will create a new Visual Studio solution from the harmonycore template. This template provides the overall solution and project infrastructure needed to create a custom Harmony Core service, and it includes all the project and NuGet package references you might need. But initially it has no pre-generated code, and Harmony Core Settings (set with the Harmony Core GUI tool) are all at their defaults.
To create a new solution:
-
Open a Windows command prompt and move to the location where you would like the solution to be created.
-
Use the following
dotnetcommand to make sure the Harmony Core templates (includingharmonycore) are installed on your machine and that you have the latest version of these templates:dotnet new install Harmony.Core.ProjectTemplates
If the Harmony Core project templates are not already installed on your machine, you should see a series of messages starting with Restore completed in....
The command line dotnet tool is also used to create new projects and solutions from pre-installed templates by using a command like this:
dotnet new harmonycore [-o <folderName>] [-n <solutionName>]
By default, the solution will be created in the current folder. However, you can use the optional -o <folderName> to create a new subfolder for the solution. And by default, the name of the new solution will be the same as the name of the containing folder, but you can override this with the -n <solutionName> option.
-
Create a new solution with the following command:
dotnet new harmonycore -o MyApi
You should see various messages like these scroll by as the solution is created:
The template "Harmony Core Starter Solution" was created successfully.
Processing post-creation actions...
Restoring C:\hc\tut\MyApi\MyApi.sln:
Determining projects to restore...
Restored C:\hc\tut\MyApi\Services\Services.synproj (in 1.33 sec).
Restored C:\hc\tut\MyApi\Services.Isolated\Services.Isolated.synproj (in 1.33 sec).
Restored C:\hc\tut\MyApi\Services.Controllers\Services.Controllers.synproj (in 1.33 sec).
Restored C:\hc\tut\MyApi\Services.Host\Services.Host.synproj (in 1.33 sec).
Restored C:\hc\tut\MyApi\Services.Models\Services.Models.synproj (in 28 ms).
Restore succeeded.
Restoring C:\hc\tut\MyApi\Repository\Repository.synproj:
Determining projects to restore...
Nothing to do. None of the projects specified contain packages to restore.
Restore succeeded.
Restoring C:\hc\tut\MyApi\Services\Services.synproj:
Determining projects to restore...
All projects are up-to-date for restore.
Restore succeeded.
Restoring C:\hc\tut\MyApi\Services.Controllers\Services.Controllers.synproj:
Determining projects to restore...
All projects are up-to-date for restore.
Restore succeeded.
Restoring C:\hc\tut\MyApi\Services.Host\Services.Host.synproj:
Determining projects to restore...
All projects are up-to-date for restore.
Restore succeeded.
Restoring C:\hc\tut\MyApi\Services.Isolated\Services.Isolated.synproj:
Determining projects to restore...
All projects are up-to-date for restore.
Restore succeeded.
Restoring C:\hc\tut\MyApi\Services.Models\Services.Models.synproj:
Determining projects to restore...
All projects are up-to-date for restore.
Restore succeeded.
Unlike when using the harmonydemo template, the code in the projects generated by the harmonycore template is not complete and will not be in a buildable form until you have configured the environment, generated some code, and added that code to various projects. Typically, you will proceed in Visual Studio from this point on.
Having used the dotnet command-line tool to create your new development solution, you can now work in Visual Studio:
-
Start Visual Studio 2022.
-
Use the
Open a Project or Solutionoption to open the new solution. -
Go to Solution Explorer. If you can't see Solution Explorer, select
View > Solution Explorerfrom the menu. -
If the contents of the Solution Explorer are expanded, start by clicking the
Collapse Allbutton on the Solution Explorer toolbar.
You should see something like this:

You have just created a "shell" environment into which you can start adding various types of data-centric or code-centric RESTful web service endpoints. The direction you take from this point will depend on your requirements, but to get a good basic understanding of how Harmony Core services are built and work, we recommend going through the remaining sections of this tutorial step-by-step.
Next topic: Enabling OData Support
-
Tutorial 2: Building a Service from Scratch
- Creating a Basic Solution
- Enabling OData Support
- Configuring Self Hosting
- Entity Collection Endpoints
- API Documentation
- Single Entity Endpoints
- OData Query Support
- Alternate Key Endpoints
- Expanding Relations
- Postman Tests
- Supporting CRUD Operations
- Adding a Primary Key Factory
- Adding Create Endpoints
- Adding Upsert Endpoints
- Adding Patch Endpoints
- Adding Delete Endpoints
-
Harmony Core CLI Tool
-
OData Aware Tools
-
Advanced Topics
- CLI Tool Customization
- Adapters
- API Versioning
- Authentication
- Authorization
- Collection Counts
- Customization File
- Custom Field Types
- Custom File Specs
- Custom Properties
- Customizing Generated Code
- Deploying to Linux
- Dynamic Call Protocol
- Environment Variables
- Field Security
- File I/O
- Improving AppSettings Processing
- Logging
- Optimistic Concurrency
- Multi-Tenancy
- Publishing in IIS
- Repeatable Unit Tests
- Stored Procedure Routing
- Suppressing OData Metadata
- Traditional Bridge
- Unit Testing
- EF Core Optimization
- Updating a Harmony Core Solution
- Updating to 3.1.90
- Creating a new Release
-
Background Information
