Skip to content

Commit b9eadfc

Browse files
committed
chore: improve documentation and fix Team name typos
- Clarify database workflow in copilot-instructions.md with detailed explanation of migration process and three use cases - Update Data/ folder description in README.md structure diagram - Add XML documentation comments for PlayerData methods - Fix team name typos - Add log function documentation in run-migrations script
1 parent 42d63f8 commit b9eadfc

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
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

scripts/run-migrations-and-copy-database.sh

100755100644
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ PROJECT_BASE_PATH="$PROJECT_ROOT_PATH/bin/Debug/net8.0"
88
SOURCE_FILE_PATH="$PROJECT_BASE_PATH/storage/$DATA_FILE"
99
TARGET_FILE_PATH="$PROJECT_ROOT_PATH/storage/$DATA_FILE"
1010

11+
# log prints a formatted log message prefixed by an emoji and timestamp, followed by the log level and message.
12+
# Parameters: emoji — emoji or symbol to prefix the entry; level — severity or level label; message — the log text.
1113
log() {
1214
local emoji=$1
1315
local level=$2
@@ -60,4 +62,4 @@ if [ -f "$TARGET_FILE_PATH" ]; then
6062
else
6163
log "⚠️" "WARNING" "Something went wrong. The destination file was not found."
6264
exit 1
63-
fi
65+
fi

src/Dotnet.Samples.AspNetCore.WebApi/Utilities/PlayerData.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.Text.Json;
1+
using System.Text.Json;
22
using Dotnet.Samples.AspNetCore.WebApi.Enums;
33
using Dotnet.Samples.AspNetCore.WebApi.Models;
44

@@ -153,6 +153,10 @@ public static List<Player> MakeStarting11()
153153
];
154154
}
155155

156+
/// <summary>
157+
/// Create a predefined starting eleven of players where each player has a fixed GUID identifier and full profile data.
158+
/// </summary>
159+
/// <returns>A list of 11 Player instances representing the starting lineup; each entry includes a predefined Id (Guid) and populated fields such as name, date of birth, squad number, position (and abbreviation), team, league, and Starting11 set to true.</returns>
156160
public static List<Player> MakeStarting11WithId()
157161
{
158162
return
@@ -311,6 +315,10 @@ public static List<Player> MakeStarting11WithId()
311315
];
312316
}
313317

318+
/// <summary>
319+
/// Create a predefined list of 15 substitute players with full profile data but without Id values.
320+
/// </summary>
321+
/// <returns>A list of 15 Player instances representing substitute players; each entry includes populated fields such as name, date of birth, squad number, position (and abbreviation), team, league, and Starting11 set to false. Id values are not assigned.</returns>
314322
public static List<Player> GetSubstitutes()
315323
{
316324
return
@@ -349,7 +357,7 @@ public static List<Player> GetSubstitutes()
349357
SquadNumber = 2,
350358
Position = Position.RightBack.Text,
351359
AbbrPosition = Position.RightBack.Abbr,
352-
Team = "Villareal",
360+
Team = "Villarreal",
353361
League = "La Liga",
354362
Starting11 = false,
355363
},
@@ -362,7 +370,7 @@ public static List<Player> GetSubstitutes()
362370
SquadNumber = 4,
363371
Position = Position.RightBack.Text,
364372
AbbrPosition = Position.RightBack.Abbr,
365-
Team = "Nottingham Forrest",
373+
Team = "Nottingham Forest",
366374
League = "Premier League",
367375
Starting11 = false,
368376
},
@@ -510,6 +518,10 @@ public static List<Player> GetSubstitutes()
510518
];
511519
}
512520

521+
/// <summary>
522+
/// Create a predefined list of 15 substitute players where each player has a fixed GUID identifier and full profile data.
523+
/// </summary>
524+
/// <returns>A list of 15 Player instances representing substitute players; each entry includes a predefined Id (Guid) and populated fields such as name, date of birth, squad number, position (and abbreviation), team, league, and Starting11 set to false.</returns>
513525
public static List<Player> GetSubstitutesWithId()
514526
{
515527
return
@@ -551,7 +563,7 @@ public static List<Player> GetSubstitutesWithId()
551563
SquadNumber = 2,
552564
Position = Position.RightBack.Text,
553565
AbbrPosition = Position.RightBack.Abbr,
554-
Team = "Villareal",
566+
Team = "Villarreal",
555567
League = "La Liga",
556568
Starting11 = false,
557569
},
@@ -565,7 +577,7 @@ public static List<Player> GetSubstitutesWithId()
565577
SquadNumber = 4,
566578
Position = Position.RightBack.Text,
567579
AbbrPosition = Position.RightBack.Abbr,
568-
Team = "Nottingham Forrest",
580+
Team = "Nottingham Forest",
569581
League = "Premier League",
570582
Starting11 = false,
571583
},

0 commit comments

Comments
 (0)