How to fix 'Add-Migration : A parameter cannot be found that matches parameter name 'ContextTypeName' '
Asked Answered
G

1

2

I have two DbContext in my project, i am trying to run EF Add-Migration pointing to a specific DbContext, but i have being encountering the below error.

Add-Migration Initial -ContextTypeName System.BLL.Contexts.TenantDbContext


Add-Migration : A parameter cannot be found that matches parameter name 'ContextTypeName'.
At line:1 char:23
+ Add-Migration InitialCreation -ContextTypeName System.BLL.Contexts.TenantDbCo ...
+                       ~~~~~~~~~~~~~~~~
   + CategoryInfo          : InvalidArgument: (:) [Add-Migration], ParameterBindingException
   + FullyQualifiedErrorId : NamedParameterNotFound,Add-Migration

I also specified the Default Project from the drop-down.

Ground answered 13/4, 2019 at 0:39 Comment(7)
No, i meant EF6. You can create a .net core project that will target .net framework, so that i can still make use of .net framework libraries.Ground
Well, I'm only able to find a ContextTypeName parameter in the Enable-Migrations command. From where did you get that?Pleasant
Like i said @Camilo, i am making use of two DbContext, so i have to specify which DbContext i am adding a migration to.Ground
So you need the -Context parameter.Neurologist
If you have your dbcontexts on different projects select your project from dropdown menu in the same powershell window, otherwise you have to include the -project too :)Chiquita
Have you installed EntityFramework? Or, do you used EntityFrameworkCore? ContextTypeName is used in Enable-Migrations. Does Add-Migration work for the only one DbContext? Is there any specific reason you need EntityFramework instead of EntityFrameworkCore.Dalmatian
Try to follow Make EF NuGet package / migrations and EF Tools work with new csproj format #231Dalmatian
H
0

You are using the parameters for EF Core, but attempting to run the command against EF 6. Context is not a valid parameter for Add-Migrations in EF6. According to multiple tutorials, the valid parameters are:

  • Name
  • Force
  • ProjectName
  • StartUpProjectName
  • ConfigurationTypeName
  • ConnectionStringName
  • IgnoreChanges
  • AppDomainBaseDirectory
  • (CommonParameters: e.g., -Debug, -Verbose)

I've found a couple sites online that both document the parameters:

Hastings answered 17/9, 2023 at 22:50 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.