无法加载文件或程序集的EntityFramework,版本=6.0.0.0,

时间:2021-09-24 03:03:48

I am working with EF . I am trying to execute this line

我在EF工作。我在试着执行这条线。

public ActionResult Edit(string id)
{           
     return View(obj.FindSemesterById(id));
}

I installed EF Version 5 on my project.

我在我的项目上安装了EF版本5。

But i get this error :

但是我得到了这个错误:

Could not load file or assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

无法加载文件或程序集的EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'或它的一个依赖项。定位组件的清单定义与程序集引用不匹配。(从HRESULT例外:0 x80131040)

My web.config file :

我的网络。配置文件:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="EducationDBEntities" connectionString="metadata=res://*/EducationModel.csdl|res://*/EducationModel.ssdl|res://*/EducationModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=EducationDB;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
      <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>

    </assemblyBinding>

  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

7 个解决方案

#1


5  

From the comments section it appears that you weren't able to install the latest version of EF from the public NuGet source because your computer didn't have direct access to the internet and was unable to resolve the www.nuget.org domain. Normally if you configure a proxy in your internet settings, Visual Studio will use this proxy when installing a NuGet from the public repository.

从评论部分看来,你无法从公共NuGet源安装最新版本的EF,因为你的计算机无法直接访问internet,无法解析www.nuget.org域名。通常,如果您在internet设置中配置一个代理,那么Visual Studio将在从公共存储库安装NuGet时使用这个代理。

So once you have installed the latest EF 6.1.0 package in your project, the error will go away. Currently you seem to be using some older version of the package and you have projects in your solution that require v6.

因此,一旦您在项目中安装了最新的EF 6.1.0包,错误就会消失。目前,您似乎正在使用一些旧版本的包,并且您的解决方案中需要v6。

#2


9  

First check which version of EF you using.

首先检查您使用的是哪个版本的EF。

You can update the EF version from NuGet Manage Pack.

您可以从NuGet管理包更新EF版本。

Go to your Project solution - > 'Manage NuGet packet for Solution', click 'Manage' on 'Entity Framework'.

去你的项目解决方案- > '管理NuGet数据包解决',点击'管理'在'实体框架'。

and also Check your app.config . Maybe the wrong version number is being referenced here.

并检查你的app.config。可能是错误的版本号在这里被引用。

Edit:

编辑:

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

It's referencing EF Version 5.0.0.0

它引用EF版本5.0.0.0。

#3


5  

Open

开放

Toos > Nuget Package Manager > Package Manager Console

then run

然后运行

PM> install-package entityframework -version 6.0.0.0

Or You can update it to latest version using below command

或者您可以使用以下命令将其更新为最新版本。

PM> Update-Package entityframework 

#4


1  

I faced the same problem today. I had 3 projects in a solution two of which had EF 6.0.0.0 and one of them had 5.0.0.0. I upgraded the version of that one project when I found this issue. The error went away.

我今天遇到了同样的问题。我在一个解决方案中有三个项目,其中两个有EF 6.0.0,其中一个有5.0.0.0。当我发现这个问题时,我升级了那个项目的版本。错误的走了。

Note: I simply went to References folder of each project and saw the properties of EntityFramework to find out the version of Entity.

注意:我只是简单地查阅了每个项目的引用文件夹,并看到EntityFramework的属性来查找实体的版本。

#5


0  

I've faced similar problem and same error as you mentioned.

我也遇到过类似的问题和你提到的错误。

I solved it differently. I noticed that EntityFramework.dll was added to packages folder under Solution Explorer. So I copied EntityFramework.dll from that folder to the bin folder under Solution Explorer and it worked. I know this is not your answer, it may be helpful to other so I just added it.

我解决了它不同。我注意到EntityFramework。将dll添加到解决方案资源管理器下的包文件夹中。所以我复制EntityFramework。从该文件夹到“解决方案资源管理器”下的bin文件夹。我知道这不是你的答案,它可能对其他的有帮助,所以我只是添加了它。

#6


0  

I had the same problem, and looking through the answers here gave me a hint. My solution has four projects in it. This is a different computer than the one I first created by solution on, so I opened Tools, then NuGet package manager, clicked "Manage NuGet Packages for Solution, found Entity Framework and clicked it once. Then clicked on the Manage button that appeared.

我也遇到过同样的问题,在这里的回答给了我一个提示。我的解决方案有四个项目。这是一个不同于我最初创建的解决方案的计算机,所以我打开了工具,然后NuGet包管理器,点击“管理解决方案的NuGet包,找到实体框架并点击它一次”。然后点击出现的管理按钮。

NuGet offered to install EF to one of my projects in the Solution, so I did that. That's when I started getting this error.

NuGet提议将EF安装到我的解决方案中的一个项目中,所以我就这么做了。当我开始犯这个错误的时候。

Going back to NuGet and checking the boxes to install EF into All of the four projects in the Solution fixed the problem.

返回NuGet并检查要将EF安装到解决方案中所有四个项目中的所有项目。

Happy again!

又快乐!

#7


0  

Use Nuget to uninstall EF then add it again, Clean and rebuild your project, that worked like a charm. The "uninstall" part in my case was critical, I did a lot of reinstallations and updates and nothing.

使用Nuget卸载EF然后再添加,清理和重建你的项目,这就像一个魅力。在我的案例中,“卸载”部分是非常重要的,我做了大量的重新安装和更新,什么都没有。

#1


5  

From the comments section it appears that you weren't able to install the latest version of EF from the public NuGet source because your computer didn't have direct access to the internet and was unable to resolve the www.nuget.org domain. Normally if you configure a proxy in your internet settings, Visual Studio will use this proxy when installing a NuGet from the public repository.

从评论部分看来,你无法从公共NuGet源安装最新版本的EF,因为你的计算机无法直接访问internet,无法解析www.nuget.org域名。通常,如果您在internet设置中配置一个代理,那么Visual Studio将在从公共存储库安装NuGet时使用这个代理。

So once you have installed the latest EF 6.1.0 package in your project, the error will go away. Currently you seem to be using some older version of the package and you have projects in your solution that require v6.

因此,一旦您在项目中安装了最新的EF 6.1.0包,错误就会消失。目前,您似乎正在使用一些旧版本的包,并且您的解决方案中需要v6。

#2


9  

First check which version of EF you using.

首先检查您使用的是哪个版本的EF。

You can update the EF version from NuGet Manage Pack.

您可以从NuGet管理包更新EF版本。

Go to your Project solution - > 'Manage NuGet packet for Solution', click 'Manage' on 'Entity Framework'.

去你的项目解决方案- > '管理NuGet数据包解决',点击'管理'在'实体框架'。

and also Check your app.config . Maybe the wrong version number is being referenced here.

并检查你的app.config。可能是错误的版本号在这里被引用。

Edit:

编辑:

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

It's referencing EF Version 5.0.0.0

它引用EF版本5.0.0.0。

#3


5  

Open

开放

Toos > Nuget Package Manager > Package Manager Console

then run

然后运行

PM> install-package entityframework -version 6.0.0.0

Or You can update it to latest version using below command

或者您可以使用以下命令将其更新为最新版本。

PM> Update-Package entityframework 

#4


1  

I faced the same problem today. I had 3 projects in a solution two of which had EF 6.0.0.0 and one of them had 5.0.0.0. I upgraded the version of that one project when I found this issue. The error went away.

我今天遇到了同样的问题。我在一个解决方案中有三个项目,其中两个有EF 6.0.0,其中一个有5.0.0.0。当我发现这个问题时,我升级了那个项目的版本。错误的走了。

Note: I simply went to References folder of each project and saw the properties of EntityFramework to find out the version of Entity.

注意:我只是简单地查阅了每个项目的引用文件夹,并看到EntityFramework的属性来查找实体的版本。

#5


0  

I've faced similar problem and same error as you mentioned.

我也遇到过类似的问题和你提到的错误。

I solved it differently. I noticed that EntityFramework.dll was added to packages folder under Solution Explorer. So I copied EntityFramework.dll from that folder to the bin folder under Solution Explorer and it worked. I know this is not your answer, it may be helpful to other so I just added it.

我解决了它不同。我注意到EntityFramework。将dll添加到解决方案资源管理器下的包文件夹中。所以我复制EntityFramework。从该文件夹到“解决方案资源管理器”下的bin文件夹。我知道这不是你的答案,它可能对其他的有帮助,所以我只是添加了它。

#6


0  

I had the same problem, and looking through the answers here gave me a hint. My solution has four projects in it. This is a different computer than the one I first created by solution on, so I opened Tools, then NuGet package manager, clicked "Manage NuGet Packages for Solution, found Entity Framework and clicked it once. Then clicked on the Manage button that appeared.

我也遇到过同样的问题,在这里的回答给了我一个提示。我的解决方案有四个项目。这是一个不同于我最初创建的解决方案的计算机,所以我打开了工具,然后NuGet包管理器,点击“管理解决方案的NuGet包,找到实体框架并点击它一次”。然后点击出现的管理按钮。

NuGet offered to install EF to one of my projects in the Solution, so I did that. That's when I started getting this error.

NuGet提议将EF安装到我的解决方案中的一个项目中,所以我就这么做了。当我开始犯这个错误的时候。

Going back to NuGet and checking the boxes to install EF into All of the four projects in the Solution fixed the problem.

返回NuGet并检查要将EF安装到解决方案中所有四个项目中的所有项目。

Happy again!

又快乐!

#7


0  

Use Nuget to uninstall EF then add it again, Clean and rebuild your project, that worked like a charm. The "uninstall" part in my case was critical, I did a lot of reinstallations and updates and nothing.

使用Nuget卸载EF然后再添加,清理和重建你的项目,这就像一个魅力。在我的案例中,“卸载”部分是非常重要的,我做了大量的重新安装和更新,什么都没有。