VSO
VSO

Reputation: 12646

Where are EF Code-First Migrations Stored?

My situation is this - I just corrupted my SQL database. The only backup I have is from a number of migrations ago. Let's say I use the backup as my database now.

How do I apply the recent migrations. They have to be stored somewhere in the db...right?

I am not only asking for a fix, but interested in this theoretically - what exactly does Get-Migrations check? What is checked when I run Update-Database? I know a Migration file gets added to the project directory. But is it in the database somewhere too?

Upvotes: 0

Views: 1400

Answers (2)

3dd
3dd

Reputation: 2530

Migrations are stored in the __MigrationHistory table of the database.

The Model column cintains a GZip-compressed XML string of you model.

You can see the following page for a nice write up http://tech.trailmax.info/2014/03/inside_of_ef_migrations/

Upvotes: 1

Uladz
Uladz

Reputation: 1968

Migrations are code(with resources for model snaphot) which should be executed to change your db. There is a table in db which tracks last applied migration (MigrationHistory).

Upvotes: 1

Related Questions