EF Core Migration Rollback: Missing Data‑Restoration Constraint
0 reputation · 24 May 2021, 10:39 UTC
EF Core Migration Rollback: Missing Data‑Restoration Constraint
The goal is to guarantee that a schema change involving data manipulation can be undone without leaving the database inconsistent.
When an Up migration transforms data—e.g., converting a string to an enum—EF Core may scaffold a Down that only reverts the schema, omitting reverse data logic. A rollback then can leave values that no longer match the original model.
EF Core executes the Down as written, with no enforcement to restore data. The unresolved decision is whether EF Core should require fully reversible Down migrations that preserve original data, or allow partial rollbacks that risk data loss.
Key questions:
- What is EF Core’s behavior when a data‑transforming migration is rolled back without data restoration?
- Will future releases enforce data‑restoration in autogenerated
Downmethods? - What safeguards can developers use to detect incomplete rollbacks in production?