Skip to content

Commit 5288f24

Browse files
committed
docs: clarify database workflow and update folder structure
- Explain database migration workflow in copilot-instructions.md - Detail three use cases: clone & run, recreate, Docker - Remove obsolete Data/ database path references
1 parent 42d63f8 commit 5288f24

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

.github/copilot-instructions.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,11 +294,26 @@ dotnet ef database update --project src/Dotnet.Samples.AspNetCore.WebApi
294294
./scripts/run-migrations-and-copy-database.sh
295295
```
296296

297-
**Important**: The `run-migrations-and-copy-database.sh` script:
298-
- Resets the placeholder database file
299-
- Runs all migrations
300-
- Copies the generated database from `bin/Debug/net8.0/storage/` to `storage/`
301-
- Requires `dotnet ef` CLI tool installed globally
297+
**Database Workflow Explained:**
298+
299+
The project maintains a **pre-seeded database** at `storage/players-sqlite3.db` to support three use cases:
300+
1. **Clone & Run** - Developers can clone the repo and run immediately without manual DB setup
301+
2. **Recreate from Scratch** - Use the script to rebuild the database with all migrations
302+
3. **Docker** - Container gets a copy of the pre-seeded database on first startup
303+
304+
**How `run-migrations-and-copy-database.sh` works:**
305+
1. **Creates empty file** at `storage/players-sqlite3.db` (version-controlled source location)
306+
2. **Runs migrations** via `dotnet ef database update`
307+
- EF Core uses `AppContext.BaseDirectory/storage/players-sqlite3.db`
308+
- During migration, `AppContext.BaseDirectory` = `bin/Debug/net8.0/`
309+
- EF Core creates/updates database at `bin/Debug/net8.0/storage/players-sqlite3.db`
310+
- Applies all migrations: creates schema, seeds 26 players (11 starting + 15 substitutes)
311+
3. **Copies migration-applied database** from `bin/Debug/net8.0/storage/` back to `storage/`
312+
- Updates the version-controlled database with latest schema + seed data
313+
- This file is included in git and copied to build output via `.csproj` configuration
314+
315+
**Requirements:**
316+
- `dotnet ef` CLI tool installed globally (`dotnet tool install --global dotnet-ef`)
302317

303318
### Docker Operations
304319
```bash

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ src/Dotnet.Samples.AspNetCore.WebApi/
7575
│ ├── Player.cs
7676
│ ├── PlayerRequestModel.cs
7777
│ └── PlayerResponseModel.cs
78-
├── Data/ # EF Core DbContext
78+
├── Data/ # EF Core DbContext and migrations
7979
│ └── PlayerDbContext.cs
8080
├── Mappings/ # AutoMapper profiles
8181
│ └── PlayerMappingProfile.cs

0 commit comments

Comments
 (0)