Search code examples
entity-frameworkdotnetnukedotnetnuke-module

Could not load file or assembly EntityFramework in DotNetNuke


I have a old module in DotNetNuke. I used EF 5 in my project:

EF

I added module to DotNetNuke and it worked properly. But when I add new module that requierd to EF 6 my module gives me an error:

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.

When installing this new module EntityFramework 6 dll file will be replaced with old version (Version=5.0.0.0) file and this causes old module doesn't work.

I read many post for solving this problem but I can't find a way for this issue.

It would be very helpful if someone could explain solution for this problem.


Solution

  • You can add this to your web.config

    <configuration>
      <runtime>
        <dependentAssembly>
          <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
          <codeBase version="6.0.0.0" href="bin/EntityFramework-6.1.3/EntityFramework.dll" />
        </dependentAssembly>
        <dependentAssembly>
          <assemblyIdentity name="EntityFramework.SqlServer" publicKeyToken="b77a5c561934e089" culture="neutral" />
          <codeBase version="6.0.0.0" href="bin/EntityFramework-6.1.3/EntityFramework.SqlServer.dll" />
        </dependentAssembly>
      </runtime>
    </configuration>
    

    You have to add a folder called EntityFramework-6.1.3 into bin folder then add two follow dll to that 1-EntityFramework.dll 2-EntityFramework.SqlServer.dll