Different versions of EntityFramework in one solution

I have an old Silverlight application that uses EF5 and cannot be upgraded to EF6. I have another project that uses EF6 with a different context, but I get:

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

I suppose this is because EF5 is already loaded (it's in the main project, don't ask me why), and it still points to the dll instead of EF6. How can I make this work?

I added:

  <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" /> <codeBase version="5.0.0.0" href="C:\Projects\project\2.1.1EF2\packages\EntityFramework.5.0.0\lib\net45\EntityFramework.dll"/> <codeBase version="6.0.0.0" href="C:\Projects\project\2.1.1EF2\packages\EntityFramework.6.1.0\lib\net45\EntityFramework.dll"/> </dependentAssembly> </assemblyBinding> </runtime> 

to my main web.config next lgos suggestion, but now I get:

{"[A] System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection cannot be added to [B] System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection. Type A is taken from 'EntityFramework, Version = 5.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089 'in the context "By default" in the location "C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Temporary ASP.NET files \ project211ef \ 97babe28 \ e7ea3fa9 \ assembly \ dl3 \ 01275099 \ 70646f08_d86ecf01 \ EntityFramework.dll '. Type B is taken from "EntityFramework, Version = 6.0.0.0, Culture = neutral, PublicKeyToken = b77a5c561934e089" in the "Default" context in the folder "C: \ Projects \ project \ 2.1.1EF2 \ packages" \ EntityFramework.6.1.0 \ Lib \ net45 \ EntityFramework.dll "." }

It appears that he is still trying to use EF5, despite the fact that he is accessing the EF6 entity section.

I fixed this by adding mandatory redirects. In main web.config I redirect the new version, and then in sub web.config redirects to the old version.

+6
source share
1 answer

It is possible to use two different versions of the assembly in the same applications by defining the assembly binding in the configuration file. I think this answer should help you.

+5
source

Source: https://habr.com/ru/post/969919/


All Articles