:System.IO.FileLoadException:无法加载文件或程序集'EntityFramework'

时间:2020-01-17 17:38:06

标签: c# entity-framework

System.IO.FileLoadException:无法加载文件或程序集 'EntityFramework,版本= 5.0.0.0,文化=中性, PublicKeyToken = b77a5c561934e089'或其依赖项之一。的 定位的程序集的清单定义与程序集不匹配 参考。 (来自HRESULT的异常:0x80131040)

App.config

htmlFor

packages.config

<?xml version="1.0" encoding="utf-8"?>
<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>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v13.0"/>
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

我尝试卸载并重新安装EF do all the Solution hear 而且我无法将目标框架更改为5,因为 我使用自动映射器

2 个答案:

答案 0 :(得分:1)

检查几件事。

  • 确保已安装的EF版本支持以下版本 .Net您正在使用。
  • 卸载并重新安装
  • 确保Nuget已安装EntityFramework软件包
  • 确保所有项目都针对相同的.NET 框架。

编辑:

EntityFramework.dll条检查您的参考书,并检查每本的版本。

答案 1 :(得分:0)

我有同样的问题,我只是确保在Web配置中的所有项目中都引用了正确的框架.Net。

我改变了

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

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework" requirePermission="false"/>