Reputation: 2366
I have an old Silverlight application that uses EF5 and can't be upgraded to EF6. I have another project that uses EF6 with a different context, but I get:
Could not load file or assembly 'EntityFramework, Version=6.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)
I'm assuming this is because EF5 is already loaded (it's in the main project, don't ask me why) and it's still pointing to that dll
instead of the EF6 one. How can I get this to 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 following lgos suggestion, but now I receive:
{"[A]System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection cannot be cast to [B]System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection. Type A originates from 'EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'Default' at 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 originates from 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'Default' at location 'C:\Projects\project\2.1.1EF2\packages\EntityFramework.6.1.0\lib\net45\EntityFramework.dll'."}
It looks like it's still trying to use EF5, despite it accessing the EF6 entity section.
I fixed this by adding binding redirects. In the main web.config
I redirect to the new version then in a sub web.config
redirect to the old version.
Upvotes: 6
Views: 4607