Skip to content
Back to skills

Change Data

ASecurity

Change the Player entity schema or the seed dataset, add EF Core migrations for both SQLite and PostgreSQL, keep test fakes in sync, and switch the active database provider (DATABASE_PROVIDER/DATABASE_URL/STORAGE_PATH). Use when changing entity fields, seed players, or migrations.

  • 10 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
developmentbashsqlapidatabase

Works with

  • api

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add nanotaboada/Dotnet.Samples.AspNetCore.WebApi --skill change-data --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Change Data?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Change Data
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nanotaboada-change-data/badge)](https://www.skillsdirectory.com/skills/nanotaboada-change-data)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: change-data
description: Change the Player entity schema or the seed dataset, add EF Core migrations for both SQLite and PostgreSQL, keep test fakes in sync, and switch the active database provider (DATABASE_PROVIDER/DATABASE_URL/STORAGE_PATH). Use when changing entity fields, seed players, or migrations.
---

# Change data

Schema changes are on the "ask before changing" list: confirm with the user and
make sure an issue exists first. Never rename the migration namespace constants
in `Migrations/ProviderSpecificMigrationsAssembly.cs`.

Source paths below are relative to `src/Dotnet.Samples.AspNetCore.WebApi/`.
Test paths start with `test/`. Repository-root files (`README.md`,
`CLAUDE.md`, `docs/`) use repository-root paths.

## Schema change

1. Update the `Player` entity in `Models/Player.cs`, then the DTOs and
   `Mappings/PlayerMappingProfile.cs`.
2. Update the entity configuration in `Data/PlayerDbContext.cs` if needed.
3. Add one migration per provider (same name for both), running from the
   repository root:

   ```bash
   # SQLite (default)
   dotnet ef migrations add <Name> --project src/Dotnet.Samples.AspNetCore.WebApi
   # PostgreSQL
   DATABASE_PROVIDER=postgres DATABASE_URL="Host=localhost;..." \
     dotnet ef migrations add <Name> --project src/Dotnet.Samples.AspNetCore.WebApi --output-dir Migrations/Npgsql
   ```

4. Review both generated migrations; do not edit migrations that are already
   merged.

## Seed data change

1. Update `Utilities/PlayerData.cs` — it is the single source of truth for
   `HasData()` in `PlayerDbContext` and for `PlayerFakes` in tests.
2. Add a data migration for both providers (as above) so existing databases
   get the change; `MigrateAsync()` applies it at startup.
3. Check `test/.../Utilities/PlayerFakes.cs` and any test that asserts on
   specific players (squad numbers, counts).

## Switch database provider

- `DATABASE_PROVIDER=postgres` selects PostgreSQL; unset (or `sqlite`) keeps
  SQLite.
- `DATABASE_URL` (required for PostgreSQL) uses the Npgsql format:
  `Host=...;Database=...;Username=...;Password=...`.
- `STORAGE_PATH` overrides the SQLite file path (default
  `AppContext.BaseDirectory/storage/players-sqlite3.db`).
- `ProviderSpecificMigrationsAssembly` loads only the active provider's
  migrations; no code change is needed to switch.

## Finish

Run `dotnet test --settings .runsettings`, update the Database section of
`README.md` if behavior changed, then run `/pre-commit`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.