47 lines
1.6 KiB
Markdown
47 lines
1.6 KiB
Markdown
# 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)
|
||
|
||
1) Create a `.env` file next to `compose.yaml`:
|
||
```text POSTGRES_PASSWORD=your_local_dev_password```
|
||
|
||
2) Start everything:
|
||
```powershell docker compose up --build```
|
||
|
||
3) 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.json` which points to `localhost: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 `.env` password matches the connection string in `compose.yaml`.
|
||
- **Port 5432 already in use**: stop the other Postgres instance or change the port mapping in `compose.yaml`. |