简体   繁体   中英

The EntityFramework package is not installed on project

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'.

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.

就我而言,重新启动 Visual Studio 会有所帮助。

Just update NuGet to 2.x. EF 5.0 requires it.

我刚刚重新启动了 Visual Studio,它工作正常。

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.

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

In my case I install Microsoft.EntityFrameworkCore.Tools package in my project! problem fixed.

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.

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

打开包管理器控制台并从包管理器控制台的下拉列表中选择默认项目并在命令窗口中使用此命令安装实体框架。

install-Package Entityframework

I have experienced with that issue I solved it by just install Microsoft.EntityFrameworkCore.Tools nuget package

that package will Enable these commonly used commands: Add-Migration Drop-Database Get-DbContext Get-Migration Remove-Migration Scaffold-DbContext Script-Migration Update-Database

尝试从项目的 Nuget 包管理器更新实体框架包,这解决了我的问题。

在我的情况下,重新安装实体包并重新启动 Visual Studio。

在我的情况下,packages.config 文件在磁​​盘上,但不在 TFS 中。

This error can happen if the Entity Framework command's target project is unloaded in the Visual Studio solution (ie 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.

should work if you are opening a project for the first time,

second click on the console project and "Set as stratup project"

安装 EntityFrameworkCore 安装 EntityFrameworkCore.SqlServer 然后关闭 Visual Studio 并重新打开问题已修复

You can also clear cache NuGet in VS. resolved my problem

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 :)

This problem can be related with conflict of two versions of EntityFramework and EntityFrameworkCore. For checking it, you can write: Get-Module in package manager console. If you see EntityFramework and EntityFrameworkCore together, you need to delete EntityFramework or dependecy that linked on EntityFramework. For searching dependency you can use search solution input in solution explorer. After deleting dependency or EntityFramework you need to restart project.

I will also add that closing and opening Visual Studio solves this problem for me. As of the time of writing this, this issue occurs on Visual Studio 2022.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM