agentleFS
codewithmukeshcodewithmukesh/dotnet-agent-kit/skills/migrate/SKILL.md

migrate

Skill853 starsChanged yesterdayMITView on GitHub

Safe migration workflow with rollback for EF Core schema migrations, .NET version upgrades and NuGet packages (`/migrate packages`: outdated, CVEs, licence traps like MediatR v13+). Use for "add migration", "update database", "schema change", ".NET upgrade", "outdated packages", "nuget audit". Do NOT use for entity or query design (use ef-core) or a full security scan (use /verify security).

  • Deletes or force-pushes

71 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use incident, sdd and 8 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • JkudjoSkill

    incident

    Production incident response — structured triage, hypothesis tree, safe remediation, incident record

    Also in 4 projects that use this

  • liatrio-labsSkill

    sdd

    Execute the Liatrio Spec-Driven Development (SDD) workflow when explicitly invoked by the user. NOTE: this skill is NOT intended to be dynamically loaded or automatically triggered; it should only ever be explicitly called by the user.

    Also in 4 projects that use this

  • agenticnotetakingSkill

    upgrade

    Apply plugin knowledge base updates to an existing generated system. Consults the Ars Contexta research graph for methodology improvements, proposes skill upgrades with research justification. Never auto-implements. Triggers on "/upgrade", "upgrade skills", "check for improvements", "update methodology".

    Also in 3 projects that use this

  • genomewalkerSkill

    checkpoint

    Save a checkpoint of task status, decisions, active files, and next steps

    Also in 5 projects that use this

  • GitHubSkill

    refactor

    Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.

    Also in 10 projects that use this

  • MicrosoftSkill

    init

    Also in 7 projects that use this

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 6 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 56 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    After modifying entity classes, DbContext configuration, or relationships

    line 33
  2. Distinctive:

    When generating SQL scripts for DBA review

    line 35
  3. Distinctive:

    Check for pending migrations and uncaptured model changes.

    line 52
  4. Distinctive:

    Use MCP tools instead of reading whole files:

    line 56
  5. Distinctive:

    If data must survive a rename/retype, use a multi-step migration with raw SQL:

    line 93
  6. Distinctive:

    Never modify a migration that is already applied — create a new one.

    line 119
  7. Very specific:

    Read references/packages.md and follow it: inventory with get_nuget_packages, check outdated and vulnerable, screen for commercial-licence …

    line 144
  8. Very specific:

    Update one package at a time with dotnet build && dotnet test between each.

    line 155

“Common” is measured: kept by at least 6 in 10 of the 56 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/migrate

What

The single migration workflow for three change types, with EF Core schema migrations as the primary flow:

  1. EF Core schema — review pending model changes, generate a descriptively named migration, review the SQL for data loss and locking risks, apply with a documented rollback path.
  2. .NET version upgrade — phased TFM/SDK/package upgrade with verification at each phase.
  3. NuGet packages (/migrate packages) — outdated, vulnerable, and commercial-licence audit, then incremental one-package-at-a-time updates so breakage is always attributable.

Shared principles: verify before applying, rollback plan always, test after every step, one logical change per migration.

When

  • After modifying entity classes, DbContext configuration, or relationships
  • "add migration", "update database", "create migration", "new table", "rename column"
  • When generating SQL scripts for DBA review
  • "upgrade to .NET 10", "version upgrade", ".NET upgrade"
  • "outdated packages", "package audit", "update packages", "dependency update", "CVE", vulnerable package or Dependabot alerts, licence concerns

How

First, classify the request: schema change → Flow A; framework upgrade → Flow B; package update or audit → Flow C (/migrate packages). Then follow that flow end to end.

Flow A: EF Core Schema Migration (primary)

Step 1: Assess current state

dotnet ef migrations list --project <InfraProject> --startup-project <ApiProject>

Check for pending migrations and uncaptured model changes.

Step 2: Review model changes

Use MCP tools instead of reading whole files:

find_symbol(name: entity or DbSet)        -- locate the changed entity
get_type_hierarchy(typeName: entity)      -- check TPH/TPT/TPC inheritance changes
find_references(symbolName: property)     -- assess downstream query impact

Confirm the change is one logical unit. If not, split into multiple migrations — mixed migrations make rollback all-or-nothing.

Step 3: Generate migration

Name describes the change, not the entity: Add|Remove|Rename|Modify + WhatChanged.

# GOOD
dotnet ef migrations add AddOrderShippingAddress --project <Infra> --startup-project <Api>
# BAD — names the entity, not the change
dotnet ef migrations add Order

Step 4: Review generated SQL

database update has no dry-run flag — preview by generating an idempotent script and reading it:

dotnet ef migrations script --idempotent --project <Infra> --startup-project <Api>

Flag and report:

  • DROP COLUMN / DROP TABLE — confirm data loss is intentional
  • ALTER COLUMN type changes — check precision loss or truncation
  • ALTER on large tables — warn about lock duration
  • New non-nullable columns — need defaults for existing rows

If data must survive a rename/retype, use a multi-step migration with raw SQL:

protected override void Up(MigrationBuilder migrationBuilder)
{
    migrationBuilder.AddColumn<string>("ContactEmail", "Customers", nullable: true);
    migrationBuilder.Sql("UPDATE \"Customers\" SET \"ContactEmail\" = \"Email\"");
    migrationBuilder.AlterColumn<string>("ContactEmail", "Customers", nullable: false);
    migrationBuilder.DropColumn("Email", "Customers");
}

Step 5: Apply and verify

dotnet ef database update --project <Infra> --startup-project <Api>
dotnet build && dotnet test   # integration tests catch schema mismatches

Step 6: Document rollback

dotnet ef database update <PreviousMigrationName> --project <Infra> --startup-project <Api>
dotnet ef migrations remove --project <Infra> --startup-project <Api>   # if unapplying from code

Never modify a migration that is already applied — create a new one.

Flow B: .NET Version Upgrade

.NET 8 and .NET 9 reached end of support on 2026-11-10, so upgrade them to .NET 10 (LTS, supported to 2028-11-14). Default target is net10.0; move to net11.0 (STS, GA 2026-11-10) only for C# 15 unions or runtime async. For 10 to 11, read knowledge/breaking-changes.md and the official .NET 11 breaking-changes list first.

  1. Assess — get_project_graph to list all TFMs; flag mixed versions.
  2. Pre-flight — all tests green, no pending EF migrations, dependencies checked for target-version compatibility, dedicated branch created (branch IS the rollback plan).
  3. Update global.json — SDK version with "rollForward": "latestMinor".
  4. Update TFMs — <TargetFramework>net10.0</TargetFramework> and <LangVersion>14</LangVersion> in .csproj or Directory.Build.props.
  5. Update packages — dotnet outdated --upgrade Major --include Microsoft.* (only after the TFM is changed), then build and fix.
  6. Adopt new features — per knowledge/dotnet-whats-new.md: TimeProvider, HybridCache, primary constructors, collection expressions.
  7. Verify — dotnet build, dotnet test, dotnet format --verify-no-changes.

Flow C: Packages (/migrate packages)

Read references/packages.md and follow it: inventory with get_nuget_packages, check outdated and vulnerable, screen for commercial-licence traps, then report in priority order (VULNERABLE, LICENSE, TFM-BLOCKED, MAJOR, MINOR/PATCH).

Two rules apply every time:

  • Do not blindly update. On a net10.0 project, Microsoft.*, System.*, and EF Core packages stay on 10.x. dotnet add package with no version can now pull 11.0.0, which needs net11.0.
  • Licence traps: MediatR v13+, AutoMapper v15+, MassTransit v9, and FluentAssertions v8+ are commercial. Pin below the boundary or migrate.

Update one package at a time with dotnet build && dotnet test between each; rollback is a git revert of the bump.

MCP Tools Used

  • find_symbol / find_references — locate entities, assess schema-change impact
  • get_type_hierarchy — entity inheritance for TPH/TPT/TPC
  • get_project_graph — TFM audit before version upgrades
  • get_diagnostics — catch warnings after migration generation or upgrades
  • get_nuget_packages — package inventory for /migrate packages

Example

User: /migrate

Claude: Checking migration state...
  Last applied: 20250710_AddOrderTable
  Model changes detected: new ShippingAddress property on Order entity.

  Creating migration: AddOrderShippingAddress
  Reviewing SQL (dotnet ef migrations script --idempotent)...
  - ALTER TABLE "Orders" ADD "ShippingStreet" text NULL
  - ALTER TABLE "Orders" ADD "ShippingCity" text NULL
  No data loss. No locking risk. Safe to apply.

  Applying migration... Done. Build: green. Tests: 34/34 passed.

  Rollback (if needed):
  dotnet ef database update AddOrderTable --project src/Infrastructure --startup-project src/Api

Related

  • ef-core — entity configuration, query patterns, migration internals
  • /verify — full verification pipeline after migration work
  • /wrap-up checkpoint — commit a safe state before risky migrations
  • knowledge/package-recommendations.md — vetted packages and licensing detail

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.