: System.IO.FileLoadException: Could not load file or assembly 'EntityFramework'

1

System.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=5.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)

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>       

I tried to uninstall and re install EF do all the Solution hear and i can't change target framework to 5 because i use automaper

c#
entity-framework
asked on Stack Overflow Jan 17, 2020 by Tareq Hajer • edited Jan 17, 2020 by Selim Yildiz

2 Answers

1

Check a couple of things.

  • Make sure the version of EF installed supports the version of .Net you're using.
  • uninstall and reinstall
  • Make sure Nuget installed EntityFramework package
  • Make sure that all the projects are targeting the same .NET Framework.

EDIT:

Check your refrences for every EntityFramework.dll Go and check the version for each one.

answered on Stack Overflow Jan 17, 2020 by Train • edited Jan 17, 2020 by Train
0

I have same problem, i just make sure that i am referencing the correct framework .Net in all the projects in web config

i change this

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

to

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework" requirePermission="false"/>
answered on Stack Overflow Jan 17, 2020 by Muhammad Sufyan

User contributions licensed under CC BY-SA 3.0