简体   繁体   中英

Could not locate assembly “EntityFramework”

I've been working on this MVC 3 application on my home computer for a while now. I'm out of town on a different computer, so I got the project from my source control. This new computer didn't have MVC 3 yet, so I installed it after I copied the project to the new computer.

A lot of my dlls (like MvcContrib.dll) were missing since I didn't set Copy Local to true when I first created the project on my home computer. So I've been going in and downloading all the missing dlls and adding them to my project.

The only one I can't find is EntityFramework.dll. I can't find a download for it, and I don't see it as a .NET dll when I try to add a reference.

在此输入图像描述

I'm getting this warning when I try to build: Could not resolve this reference. Could not locate the assembly "EntityFramework"

This can also happen when you manually remove the EntityFramework reference in a project.

If you've lost the reference you can remove the entry in packages.config for EntityFramework

<packages>
    <package id="EntityFramework" version="5.0.0" targetFramework="net40" />
</packages>

After removal you are able to re-install the package through the Package Manager (Manage NuGet Packages)

Download and install Framework 4.0 and it's included.

http://www.microsoft.com/download/en/details.aspx?id=17851

You need to download and install Entity Framework separately:

http://blogs.msdn.com/b/adonet/archive/2011/04/11/ef-4-1-released.aspx

If you have not - install the Nuget extension in Visual Studio.

Using Nuget will not only enable you to have the packages with the source (in the packages directory), but will also help you keep things up to date. External dependencies you rely on should ideally be included with your solution so situations like yours do not occur.

As The Evil Greebo noted, you will need to go here to obtain the Visual Studio tooling. While the Nuget package will provide the code level support, the tooling is in the installer. I use both, so if there is an update to the package, it will show up in the Nuget update notices.

I resolved a similar problem myself by downloading the ASP.NET MVC Tools Update. Any chance you are just missing that on this other computer?

If EntityFramework was installed previously you can also manually add reference with browse. Select the following file in your project folder: \\packages\\EntityFramework.5.0.0\\lib\\net4x\\EntityFramework.dll

Then add the following if missing in your packages.config:

<packages>
    <package id="EntityFramework" version="5.0.0" targetFramework="net4x" />
</packages>

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