HPC
Technologies
- ASP.NET Core 5
- Entity Framework Core 5
- Angular 12
- ngx-admin
- MediatR
- AutoMapper
- FluentValidation
- NUnit, FluentAssertions, Moq & Respawn
TODO:
Docker
Getting Started
Command
- Install the latest .NET 5 SDK
- Install the latest Node.js LTS or nvm / nvm-windows
- Navigate to
src/WebUI/ClientApp
and runnpm install
- Navigate to
src/WebUI/ClientApp
and runnpm start
to launch the front end (Angular) - Navigate to
src/WebUI
and rundotnet run
to launch the back end (ASP.NET Core Web API) - Go to https://localhost:5001/
- Demo user:
admin@hpc.io
/P@ssw0rd
Visual Studio
TODO:
Testing
Go to root
folder: ~\workspace\HPC\
$ dotnet test HPC.sln
Docker Configuration
TODO:
Database Configuration
The template is configured to use an in-memory database by default for development purpose. This ensures that all users will be able to run the solution without needing to set up additional infrastructure (e.g. SQL Server).
When you run the application the database will be automatically created (if necessary) and the latest migrations will be applied.
Database Migrations
To use dotnet-ef
for your migrations please add the following flags to your command (values assume you are executing from repository root)
--project src/Infrastructure
(optional if in this folder)--startup-project src/WebUI
--output-dir Persistence/Migrations
For example, to add a new migration from the src
folder: ~\workspace\HPC\src\
Add a new migration
$ dotnet ef migrations add AddShipEntity -p src\Infrastructure -s src\WebUI -o Persistence\Migrations
Update database
$ dotnet ef database update -p src\Infrastructure -s src\WebUI
$ dotnet ef database update InitialCreateWithIdentity -p src\Infrastructure -s src\WebUI
Remove the latest migration
$ dotnet ef migrations remove -p src\Infrastructure -s src\WebUI
Angular CLI
If you want to add a new angular component, server, or model, follow below commands
Add a new component and child components
$ ng g c ships -s --skip-tests --module app
$ ng g c ships/show-ship -s --skip-tests --module app
$ ng g c ships/add-edit-ship -s --skip-tests --module app
Add a new service
$ ng g s shared/ship --skip-tests
Add a new model
$ ng g class shared/ship --type=model --skip-tests
Troubleshooting
-
warning:
The EF Core tools version '3.x.x' is older than that of the runtime '5.0.8'. Update the tools for the latest features and bug fixes.
$ dotnet tool update --global dotnet-ef
-
Unable to resolve service for type
'Microsoft.EntityFrameworkCore.Migrations.IMigrator'
. This is often because no database provider has been configured for this DbContext. A provider can be configured by overriding the 'DbContext.OnConfiguring' method or by using 'AddDbContext' on the application service provider. If 'AddDbContext' is used, then also ensure that your DbContext type accepts a DbContextOptions object in its constructor and passes it to the base constructor for DbContext.$ use Database instead of InMemory by configuring '"UseInMemoryDatabase": false' in appsetting.json
-
Get 500 internal server error after restart application and you are using
UseInMemoryDatabase
, try to clear browser's cookie. This may relate to logged in User Id from seeded data has gone
Overview
Domain
This will contain all entities, events, and logic specific to the domain layer.
Application
The biggest layer containing all application logic that is dependent on the domain layer, but has no dependencies on any other layer or project. This layer defines interfaces that are implemented by outside layers. For example, if the application needs to access a notification service, a new interface would be added to the application and implementation would be created within Infrastructure.
Infrastructure
This layer contains classes for accessing external resources such as database, file systems, web services, smtp, and so on. These classes should be based on interfaces defined within the application layer. Moreover, this layer will publish all registered events on each request.
WebUI
This layer is a single-page application based on Angular 12 and ASP.NET Core 5. This layer depends on both the Application and Infrastructure layers, however, the dependency on Infrastructure is only to support dependency injection. Therefore only Startup.cs should reference Infrastructure.