问题
I am having trouble getting the EF to install on my very simple project called 'Match' (just now learning MVC, better late than never). The general context here is that I created the Model class with only 2 fields and now I want to change the Model class to have a few more fields/properties. I have made the change in the Model class and am now trying to update the DB to match. I am trying to use Update-Database from EF to do that.
PM> install-package EntityFramework You are downloading EntityFramework from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=253898&clcid=0x409. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device. Successfully installed 'EntityFramework 5.0.0'. Successfully added 'EntityFramework 5.0.0' to Match.
Type 'get-help EntityFramework' to see all available Entity Framework commands.
PM> Enable-Migrations Get-Package : A parameter cannot be found that matches parameter name 'ProjectName'. At C:\Users\Dave\Documents\Visual Studio 2010\Projects\Match\packages\EntityFramework.5.0.0\tools\EntityFramework.psm1:611 char:40 + $package = Get-Package -ProjectName <<<< $project.FullName | ?{ $_.Id -eq 'EntityFramework' } + CategoryInfo : InvalidArgument: (:) [Get-Package], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,NuGet.PowerShell.Commands.GetPackageCommand
The EntityFramework package is not installed on project 'Match'.
回答1:
Just update NuGet to 2.x. EF 5.0 requires it.
回答2:
Hopefully no-one is as stupid as me, but for the benefit of searchers:
One possibility for this error - In the Package Manager Console, there is a dropdown for 'Default Project'. If this is set incorrectly, you will get The EntityFramework package is not installed on project 'x'. Change the dropdown to your EF project and all is good again.
回答3:
In my case, restarting the Visual Studio helped.
回答4:
In my case I had a project that for some reason did not have a Packages.config file. The result was I got the error mesage "The EntityFramework package is not installed on project xxxx".
To solve this simply add a Packages.config file and "Install-Package EntityFramework" then works.
回答5:
In my projects I installed EntityFramework on them separately. Even though they all had the same version numbers on each project, it still didn't work. Resulting in the same error you get.
To fix this, I removed EntityFramework from all my projects and reinstalled it again.
Get-Project -all | Uninstall-Package EntityFramework
Next, you just reinstall it again.
Get-Project -all | Install-Package EntityFramework
回答6:
I have the same problem. I have added EFCore to a project that has installed EF6. so add-migration xx command performed with EF6 instated of EFCore and I get this error. removing EF6 and restarting Visual Studio solved my problem.
回答7:
You will have to install the EF into your project. You can do that via Tools|Manage NuGet Packages, look under 'Installed' and click on 'Manage'. There you will see an option to install EF in your project. After that everything should work and modelchanges will be possible. It can take quite some time (in my case, it did!). Success! Peter
回答8:
In my case I install Microsoft.EntityFrameworkCore.Tools package in my project! problem fixed.
回答9:
Open package manager console and select default project from dropdown in package manager console And Install entity framework using this command in command window.
install-Package Entityframework
回答10:
I have just restarted Visual Studio and it worked.
回答11:
Try to update the Entity Framework Package, from the Nuget Package Manager of your project, that's solved my problem.
回答12:
In my case the packages.config file was on disk but not in TFS.
回答13:
This error can happen if the Entity Framework command's target project is unloaded in the Visual Studio solution (i.e. if you'd previously right-clicked the project in Solution Explorer and selected "Unload Project").
In this case, the solution is to load the project, then try running the Entity Framework command again.
回答14:
should work if you are opening a project for the first time,
second click on the console project and "Set as stratup project"
回答15:
install EntityFrameworkCore install EntityFrameworkCore.SqlServer And Then Close Visual Studio And reopen Problem Fixed
回答16:
You can also clear cache NuGet in VS. resolved my problem
回答17:
In my case, I have a Xamarin.Forms solution with three projects - Backend (for Azure Database connection), one common library, an iOS project and an Android project. The error messages that I have received were "The EntityFramework package is not installed on project ..." and "No context type was found in the assembly ...". I have solved it by setting Backend as my StartUp project and then by entering the commands in the following format in the Package Manager Console:
Enable-Migrations -ProjectName Backend -Verbose
and after that
add-migration -ProjectName Backend Initial
I hope that this is of help for someone :)
来源:https://stackoverflow.com/questions/11923077/the-entityframework-package-is-not-installed-on-project