JVK
JVK

Reputation: 88

EFCore run single migration

the migration table in the database is non existant so I am trying to run 1 specific migration that didnt run yet. I tried using the -target and -migration flag but those do not seem to exist.

I am now trying the -SourceMigration flag without result.

Update-Database -SourceMigration 202107031357360_LoginTokens

the Applying code-based migrations: output keeps on showing that it wants to run the full list of migrations

Upvotes: 0

Views: 1426

Answers (1)

CodeCaster
CodeCaster

Reputation: 151720

the Applying code-based migrations: output keeps on showing that it wants to run the full list of migrations

... Because according to your __MigrationHistory table, none of the existing migrations have been applied. Migrations are like a stack, you can't just run a random migration in the middle, you have to start from the bottom.

If your database already exists and can't be recreated, you can manually insert the records for migrations that you know were applied. You could for example copy the structure and contents from your development database.

Then you can update to the desired migration.

Upvotes: 3

Related Questions