Is it possible to downgrade an Entity Framework Core code-first migration without the migration present in the code base?

41 views Asked by At

Imagine a micro services architecture using EF Core code first with migrations.

A kubernetes init container will migrate the SQL Server database before running the actual application container.

But sometimes we rollback to a previous version of the application. This means the database is in an invalid and possibly incompatible state.

I would like to migrate the database back to the most recent migration present in the code base of that version, but the down migration won't be know.

Is it possible at all to facilitate this? I guess the database itself needs knowledge about the way to migrate back, but is it possible?

I did some research but it seems to me this scenario is unsupported at the time of writing.

0

There are 0 answers