-
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 custom Harmony Core service that you can easily customize to meet your exact needs.
In the following steps, you will create a new development solution from the harmonycore
template. The template provides the overall solution and project infrastructure is needed to create a custom Harmony Core service and has all of the project and Nuget package references that you might need already in place, but the regen batch file is in a pristine state, and the solution does not contain any pre-generated code. When using this template you are responsible for specifying the data structures and features that your service will have.
To use the template to create a new solution you use a command similar to this:
dotnet new harmonycore [-o <folderName>] [-n <solutionName>]
The optional -o <folderName>
allows you to create a new subfolder for the solution, by default the solution will be created in the current folder. The name of the new solution will be the same as the name of the containing folder, but you can override it by specifying the -n <solutionName>
option to provide a custom name for the solution.
To create a new solution:
-
Open a Windows command prompt and move to the location where you would like the solution to be created.
-
Create a new solution with the following command:
dotnet new harmonycore -o MyApi
You should see various messages scroll by as the solution is created, like this:
The template "Harmony Core Starter Solution" was created successfully.
Processing post-creation actions...
Running 'dotnet restore' on MyApi\MyApi.sln...
Restore completed in 458.49 ms for D:\MyApi\Services.Isolated\Services.Isolated.synproj.
Restore completed in 458.49 ms for D:\MyApi\Services.Controllers\Services.Controllers.synproj.
Restore completed in 458.49 ms for D:\MyApi\Services.Host\Services.Host.synproj.
Restore completed in 458.48 ms for D:\MyApi\Services\Services.synproj.
Restore completed in 458.49 ms for D:\MyApi\Services.Models\Services.Models.synproj.
Restore succeeded.
Running 'dotnet restore' on MyApi\Repository/Repository.synproj...
Nothing to do. None of the projects specified contain packages to restore.
Restore succeeded.
Running 'dotnet restore' on MyApi\Services/Services.synproj...
Restore completed in 32.96 ms for D:\MyApi\Services.Isolated\Services.Isolated.synproj.
Restore completed in 32.99 ms for D:\MyApi\Services\Services.synproj.
Restore completed in 32.94 ms for D:\MyApi\Services.Models\Services.Models.synproj.
Restore completed in 32.93 ms for D:\MyApi\Services.Controllers\Services.Controllers.synproj.
Restore succeeded.
Running 'dotnet restore' on MyApi\Services.Controllers/Services.Controllers.synproj...
Restore completed in 29.27 ms for D:\MyApi\Services.Models\Services.Models.synproj.
Restore completed in 29.24 ms for D:\MyApi\Services.Controllers\Services.Controllers.synproj.
Restore succeeded.
Running 'dotnet restore' on MyApi\Services.Host/Services.Host.synproj...
Restore completed in 28.72 ms for D:\MyApi\Services.Models\Services.Models.synproj.
Restore completed in 28.72 ms for D:\MyApi\Services.Isolated\Services.Isolated.synproj.
Restore completed in 28.74 ms for D:\MyApi\Services\Services.synproj.
Restore completed in 28.72 ms for D:\MyApi\Services.Controllers\Services.Controllers.synproj.
Restore completed in 37.26 ms for D:\MyApi\Services.Host\Services.Host.synproj.
Restore succeeded.
Running 'dotnet restore' on MyApi\Services.Isolated/Services.Isolated.synproj...
Restore completed in 27.17 ms for D:\MyApi\Services.Controllers\Services.Controllers.synproj.
Restore completed in 27.2 ms for D:\MyApi\Services.Isolated\Services.Isolated.synproj.
Restore completed in 27.17 ms for D:\MyApi\Services.Models\Services.Models.synproj.
Restore succeeded.
Running 'dotnet restore' on MyApi\Services.Models/Services.Models.synproj...
Restore completed in 25.96 ms for D:\MyApi\Services.Models\Services.Models.synproj.
Restore succeeded.
D:\>
Unlike when using the harmonydemo
template, the code in the projects generated by the harmonycore
template is not complete and is not 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.
Having used the dotnet
command-line tool to create your new development solution you can now work in Visual Studio.
-
Start Visual Studio 2019
-
Use the
Open a Project or Solution
option to open the new solution. -
Go to Solution Explorer. If you can't see Explorer, select
View -> Solution Explorer
from the menu. -
If the contents of the Solution Explorer are expanded, start by clicking the
Collapse All
button.
You should see something like this:
In the previous steps, you have created a "shell" environment into which you can start adding various types of data-centric or code-centric RESTful Web Service endpoints. The direction that 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 following a specific path through the remaining tutorials.
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 Code Generator
-
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