You can run the entire project locally using docker compose.
docker compose up
If you need do debug the WebApi project in an IDE, you can alternatively run docker compose without the WebAPI.
First create a dotnet user secret for the DB connection string.
dotnet user-secrets set -p .\src\Digdir.Domain.Dialogporten.WebApi\ "Infrastructure:DialogDbConnectionString" "Server=localhost;Port=5432;Database=Dialogporten;User ID=postgres;Password=supersecret;"
Then run docker compose without the WebAPI project.
docker compose -f docker-compose-no-webapi.yaml up
This project uses Entity Framework core to manage DB migrations. DB development can ether be done through Visual Studios Package Manager Console (PMC), or through the CLI.
Set Digdir.Domain.Dialogporten.Infrastructure as startup project in Visual Studios solution explorer, and as default project in PMC. You are now ready to use EF core tools through PMC. Run the following command for more information:
Get-Help about_EntityFrameworkCore
Install the CLI tool with the following command:
dotnet tool install --global dotnet-ef
You are now ready to use EF core tools through CLI. Run the following command for more information:
dotnet ef --help
Remember to target Digdir.Domain.Dialogporten.Infrastructure
project when running the CLI commands. Either target it throguh the command using the -p
option, i.e.
dotnet ef migrations add -p .\src\Digdir.Domain.Dialogporten.Infrastructure\ TestMigration
or change your directory to the infrastructure project, and then run the command.
cd .\src\Digdir.Domain.Dialogporten.Infrastructure\
dotnet ef migrations add TestMigration