HomeChallengesRepsProblemsLeaderboardTake a challenge

The migration that lost a column

The scaffolder saw a renamed property and generated a drop and an add. It would have passed review and deleted every customer name in production. Rewrite it so the data survives, and so adding a required column works on a table that already has rows.

Advanced20 min on the clock5 graded checks · 100 pointsPersistence with EF CorePro
Graded by reading your code against the checklist below.

What you build

  • Rename the column instead of dropping and adding it
  • Add the new required column as nullable first
  • Backfill it
  • Only then make it NOT NULL
  • A Down that actually reverses the Up

Done means

Running Up on a populated table changes shape and loses nothing, and Down puts it back.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. The rename is a rename+30Querying a database
  2. The new column arrives nullable+25Querying a database
  3. Existing rows are given a value+20Writing a row safely
  4. Only then is it made required+15Querying a database
  5. Down reverses what Up did+10Querying a database

What it teaches

Writing a row safelybeginner

Creating a record means deciding its id, checking it before it lands, and never modifying the list you were handed — because a half-written row is harder to find and fix than a rejected request.

The rest of Persistence with EF Core