Integrate PostgreSQL with EF Core & migrations

Add PostgreSQL support and EF Core migrations for local development. Introduces ApplicationDbContext, adds Npgsql.EntityFrameworkCore.PostgreSQL and EF Core Design packages, and includes generated migrations (InitialPostgres and RemoveTestItems) plus updated model snapshot. Program.cs now loads an optional API/appsettings.custom.json, configures the DbContext from ConnectionStrings:Postgres and runs Database.Migrate() on startup. Adds a Dev docker-compose.yml to run postgres + pgAdmin, pins dotnet-ef in dotnet-tools.json, and adds ConnectionStrings to appsettings files. Also ignores API/appsettings.custom.json in .gitignore and updates README/codexInfo to document the new DB/dev workflow.
This commit is contained in:
Jonas
2026-04-18 17:40:42 +02:00
parent db8ed2a868
commit fcd2dca8dc
15 changed files with 293 additions and 1 deletions
+38
View File
@@ -0,0 +1,38 @@
services:
postgres:
image: postgres:16-alpine
container_name: hoard-postgres
restart: unless-stopped
environment:
POSTGRES_DB: hoard
POSTGRES_USER: hoard
POSTGRES_PASSWORD: hoard_dev_password
ports:
- "5432:5432"
volumes:
- hoard_postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U hoard -d hoard"]
interval: 10s
timeout: 5s
retries: 5
pgadmin:
image: dpage/pgadmin4:9.3
container_name: hoard-pgadmin
restart: unless-stopped
environment:
PGADMIN_DEFAULT_EMAIL: familiehimmelberg@gmail.com
PGADMIN_DEFAULT_PASSWORD: admin
PGADMIN_CONFIG_SERVER_MODE: "False"
ports:
- "5050:80"
depends_on:
postgres:
condition: service_healthy
volumes:
- hoard_pgadmin_data:/var/lib/pgadmin
volumes:
hoard_postgres_data:
hoard_pgadmin_data: