104

I am trying to figure out how to run a specific migration from the package manager in nuget.

I have tried to run:

 update-database -TargetMigration test32

But I do get this message:

A parameter cannot be found that matches parameter name 'TargetMigration'.

How can this be resolved?

ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122
stian64
  • 1,563
  • 3
  • 12
  • 25

5 Answers5

181

According to EF Core Docs, correct parameter name is -Target (for EF Core 1.1) or -Migration (for EF Core 2.0)

so in your case:

update-database -target test32

or

update-database -migration test32

"Modern" way is to use "regular" command prompt and .NET Core CLI, and command like dotnet ef database update <target>

Dmitry
  • 16,110
  • 4
  • 61
  • 73
85

The best answer given by Dmitry is a bit incorrect. There's no parameter -Target. The only parameter that can be applied is -Migration. Therefore, the right answer is:

Update-Database -Migration test32
Plastiquewind
  • 867
  • 6
  • 8
  • 14
    Can confirm. core 2.0 uses -migration. -target is no longer reconized – JSON Mar 20 '19 at 13:58
  • 2
    This applies all the missing migrations up to the provided one (`test32`), which is what you normally want since migrations might one upon the other and must be run in order. – Alexei - check Codidact Aug 25 '21 at 11:40
26

For EF Core 3.1 via Package Manager Console:

dotnet ef database update YourMigrationName
5

Just wanted to add to what Plastiquewind mentioned. In the current version, there is no -target parameter. You have to use -migration. Also, you can specify the context (if you have more than one) with the -context parameter.

Update-database -context MyContext -migration MyMigration
SimpleUser
  • 1,341
  • 2
  • 16
  • 36
0

For mac i did like this working for me

dotnet ef database update -c ApplicationDbContext
sweetnandha cse
  • 705
  • 7
  • 16