1.6 KiB
Freman.Sample.Web – Blazor + PostgreSQL (Docker) sample
This repo is a small demo for C# developers (e.g., Unity folks) who are new to web dev.
Prereqs
- Docker Desktop
- .NET SDK (matching the repo)
- (Optional) EF tooling:
dotnet-ef
Quickstart (recommended)
-
Create a
.envfile next tocompose.yaml:text POSTGRES_PASSWORD=your_local_dev_password -
Start everything:
powershell docker compose up --build -
Open the app, then navigate to Notes (Postgres). Type a note, click Save, refresh the page — it should persist.
Running from Rider (server on host, DB in Docker)
Start just Postgres:
powershell docker compose up postgres
Then run the Freman.Sample.Web project from Rider.
In this mode, the app uses
appsettings.Development.jsonwhich points tolocalhost:5432.
Migrations (EF Core)
Install EF CLI once:
powershell dotnet tool install --global dotnet-ef
Add a migration:
powershell dotnet ef migrations add InitialCreate --project .\Freman.Sample.Web\Freman.Sample.Web\Freman.Sample.Web.csproj --startup-project .\Freman.Sample.Web\Freman.Sample.Web\Freman.Sample.Web.csproj ` --output-dir Data\Migrations
Apply it:
powershell dotnet ef database update --project .\Freman.Sample.Web\Freman.Sample.Web\Freman.Sample.Web.csproj --startup-project .\Freman.Sample.Web\Freman.Sample.Web\Freman.Sample.Web.csproj
Troubleshooting
- DB auth failed: check
.envpassword matches the connection string incompose.yaml. - Port 5432 already in use: stop the other Postgres instance or change the port mapping in
compose.yaml.