@@ -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
0 commit comments