【问题标题】:: System.IO.FileLoadException: Could not load file or assembly 'EntityFramework':System.IO.FileLoadException:无法加载文件或程序集“EntityFramework”
【发布时间】:2020-05-04 15:17:19
【问题描述】:

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

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

packages.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="AutoMapper" version="9.0.0" targetFramework="net462" />
  <package id="EntityFramework" version="5.0.0" targetFramework="net462" />
</packages>       

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

【问题讨论】:

  • 什么版本的.net?我看到你已经为 4.6.2 安装了它,但你用的是什么?
  • 我确定我使用的是 .net 4.6.2

标签: c# entity-framework


【解决方案1】:

检查几件事。

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

编辑:

检查每个EntityFramework.dll 的引用去检查每个的版本。

【讨论】:

  • 我相信你所说的一切。但它仍然不起作用谢谢。
  • 别担心,它是 v 5
【解决方案2】:

我有同样的问题,我只是确保我在 web config 中的所有项目中引用了正确的框架 .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"/>

【讨论】:

  • 我尝试卸载并重新安装 EF do all the Solutionhear 并且我无法将目标框架更改为 5,因为我使用了 automaper
  • 在 git 或其他软件上分享源代码,以便我检查。如果你没有问题。
猜你喜欢
  • 2013-08-13
  • 1970-01-01
  • 2014-05-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-06-06
  • 1970-01-01
相关资源
最近更新 更多