dev.tirsvad.dk
Tirsvad Website: A Clean Architecture .NET solution using Blazor WebAssembly for modern, cloud-ready web applications. Supports SQLite/MySQL, containerization, and follows best practices for maintainability and scalability.
dev-tirsvad-dk Directory Reference
Directory dependency graph for dev-tirsvad-dk:
src/WebUI/WebUI/wwwroot/projects/Tirsvad/dev-tirsvad-dk

Detailed Description

Tirsvad.WebSite.DevTirsvadDk

The website serves as a platform for sharing updates, features, and progress related to Tirsvad development and its affiliated projects. It provides a centralized location for developers, contributors, and users to stay informed about the latest developments, access resources, and engage with the Tirsvad community. Its content have quality requirements, and it is expected to be regularly updated with relevant information about Tirsvad and its ecosystem.

Table of Contents

Configuration

Environment variables

Variable Name Default value Description
WWW_HOSTNAME Overrides the hostname in GetHostFromNavigationManager().
PROJECTS_ROOT Overrides the root path for the website.
NUGET_LOCAL_HOST_PATH Path to the local NuGet package source. Set in .env file.
ConnectionStrings__DefaultConnection Connection string for the default database connection. Set in appsettings.json or environment variables.

Local NuGet Feed Setup

To use a local NuGet feed, set the environment variable in a .env file at the solution root:

NUGET_LOCAL_HOST_PATH=C:\path\to\local\nuget\feed

Configuration Management

This solution uses the standard ASP.NET Core configuration system. Configuration settings are managed via appsettings.json files, with overrides for each environment (e.g., appsettings.Development.json, appsettings.Production.json). Environment variables and user secrets (for development) are also supported.

For more details, see the official Microsoft documentation.

Entity Framework Core: Initialization & Updates

Install EF Core Tools

Install EF Core CLI tools if not already present:

dotnet tool install --global dotnet-ef

Add a Migration

To create a new migration after updating your models or DbContext:

dotnet ef migrations add <MigrationName> --project src/Infrastructure --startup-project src/WebUI/WebUI

Update the Database

To apply migrations and update the database schema:

dotnet ef database update --project src/Infrastructure --startup-project src/WebUI/WebUI

Workflow

Server-Side Setup

Setup user and role management

-- Step 1: Create the role with login privilege and password
CREATE ROLE "exampleRole" LOGIN PASSWORD 'secr3t';
-- Step 2: (Optional) Grant privileges if needed
-- For example, allow the user to create databases:
ALTER ROLE "exampleRole" CREATEDB;
-- Step 3: Create a database owned by the new role
CREATE DATABASE "exampleDatabase" OWNER "exampleRole";
-- Step 4: Verify the role exists
\du
-- Step 5: Verify the database exists
\l

Troubleshooting

For more details, see the official EF Core documentation.

MigrationRunner: Overview & Usage

What is MigrationRunner?

MigrationRunner is a migration management tool for .NET projects, typically used to apply, revert, and track database schema changes. It ensures your database stays in sync with your application models and supports versioned migrations for reliable deployments.

How to Use MigrationRunner

TODO: Provide specific commands and examples for using MigrationRunner in this project.

Best Practices

Publish & Deployment Workflow (WebUI and MigrationRunner)

Standard Publish & Deploy

  1. Publish both projects:
    dotnet publish src/WebUI/WebUI -c Release -o g/publish/WebUI/release/
    dotnet publish src/MigrationRunner/MigrationRunner -c Release -o g/publish/MigrationRunner/release/
  2. Deploy using deploy.dev.tirsvad.dk.sh:
    • The script uploads both published folders to the server.
    • MigrationRunner is executed remotely to update the database.
    • Services are restarted.

Docker Workflow

  1. Build Docker images:
    docker build -t devtirsvad-webui -f src/WebUI/WebUI/Dockerfile .
    docker build -t devtirsvad-migrationrunner -f src/MigrationRunner/MigrationRunner/Dockerfile .
  2. Push images to your registry (if needed):
    docker push <your-registry>/devtirsvad-webui
    docker push <your-registry>/devtirsvad-migrationrunner
  3. Deploy using docker-compose or Kubernetes. Example docker-compose.yml:
    version: '3.8'
    services:
    webui:
    image: devtirsvad-webui
    ports:
    - "80:80"
    depends_on:
    - migrationrunner
    migrationrunner:
    image: devtirsvad-migrationrunner
    command: ["dotnet", "MigrationRunner.dll"]