Reputation: 1168
I am following this tutorial to practice MVC-4: http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-a-new-field-to-the-movie-model-and-table
I am not doing the same example. I am just using it as a guideline to try something of my own.
I've come across this problem:
After I open the package manager console
I get the following error after trying to enable migrations for my context:
PM> Enable-Migrations -ContextTypeName MvcAuction.Models.AuctionDBContext
Enable-Migrations : A parameter cannot be found that matches parameter name 'ContextTypeName'.
At line:1 char:35
+ Enable-Migrations -ContextTypeName <<<< MvcAuction.Models.AuctionDBContext
+ CategoryInfo : InvalidArgument: (:) [Enable-Migrations], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Enable-Migrations
Any ideas how this might be resolved?
Upvotes: 1
Views: 24756
Reputation: 1393
Enable Migrations is now obsolete, you can add like this:
EntityFrameworkCore\Add-Migration yourMessageHere -Context AppContext
Upvotes: 0
Reputation: 71
When I removed Z.EntityFramework.Plus.EFCore package problem was solved
Upvotes: 0
Reputation: 1
For anyone still struggling after trying the other solutions.
After wasting 2 hours trying to restart VS, updating VS and restarting my PC. I finally solved this by changing my git branch and then adding the migration.
Upvotes: 0
Reputation: 704
Update-Database : A parameter cannot be found that matches parameter name 'ConfigurationTypeName'. At line:1 char:17
Such errors where parameter name does not match suggests the version of the command does not support that parameter. It can be due to the version of the EF tools installed on the VS project. In my case, I have 2 projects one with EF 6.x and other with EF Core installed and apparently EF core takes precedence so, when using EF 6.X I had to use EntityFramework\Update-Database and EntityFrameworkCore\Update-Database.
Upvotes: 3
Reputation: 2690
I had the same issue but got it to work by selecting the project in the drop down menu of the Nuget Package Manager Console and then removing the fully qualified path, so:
PM> Enable-Migrations -ContextTypeName ApplicationDbContext
Upvotes: 2
Reputation: 319
EDIT: It seems that the context type may not be existing or is not placed under the models namespace.
The syntax is
Enable-Migrations -ContextTypeName NameOfYourDataContextType
The NameOfYourDataContextType is the context you add when adding a controller.
So you type in the whole shown in this:
Or use the existing which is shown:
It would be
Enable-Migrations -ContextTypeName MvcApplication4.Models.MvcApplication4Context
Enable-Migrations -ContextTypeName MvcApplication4.Models.ExternalLogin
The syntax : Enable-Migrations will only work if you only have one context in your project.
Came across this problem upon taking this tutorial
Upvotes: 0
Reputation: 310
I had this very same error when working on "quick-and-dirty" ASP.net web site.
In ASP.Net Web sites, non-pages classes are put in the App_code directory. They are compiled to form a separate assembly.
May be the package manager didn't manage (!) to find the context type name in this "App_Code" assembly (the error message looks weird).
I solved the problem by moving the model and context classes into another class library project.
I don't know what could be the problem with MVC 4, but my experience could help another Web Form developer...
Upvotes: 0
Reputation:
"Enable-Migrations -ContextTypeName MvcMovie.Models.MovieDBContext"
MvcMovie change to MvcYourApplicationName.
Upvotes: 1
Reputation: 21
I too had the same issue. I fixed it by upgrading the EntityFramework through NuGet to version 5.0.0. If you are facing issue with EntityFramework.5.0.0 , please try re-installing it.
Upvotes: 2
Reputation: 12323
A parameter cannot be found that matches parameter name 'ContextTypeName'.
Looks to me like you're using an older version of Entity Framework (4.3?) which doesn't have that parameter implemented. Works for me and I use EF 5.
PM> enable-migrations -contexttypename test3.Models.UsersContext Checking if the context targets an existing database... Code First Migrations enabled for project test3.
Upvotes: 0
Reputation: 1168
For those who might stumble uppon the same problem in the future. I already solved it by just using Enable-Migrations without the -ContextTypeName.
Upvotes: 2