不同的EntityFramework版本相同的解决方案 [英] Different EntityFramework versions in same solution
问题描述
我有一个使用EF5,不能升级到EF6旧的Silverlight应用程序。我有一个使用EF6具有不同的上下文中的另一个项目,但我得到:
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:
无法加载文件或程序集的EntityFramework,版本= 6.0 .0.0,
区域性=中性公钥= b77a5c561934e089'或一个
依赖关系之一。找到的程序集清单定义不
匹配程序集引用。 (异常来自HRESULT:0x80131040)
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)
我假设这是因为EF5已经被加载(它是在主项目,不要' ŧ问我为什么),它仍然指向到的 DLL
而不是EF6之一。 ?我怎样才能得到这个工作。
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?
我说:
<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>
我的主要的web.config以下lgos建议,但现在我得到:
to my main web.config following lgos suggestion, but now I receive:
{[A] System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection不能转换为[b] System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection 。类型从起源的EntityFramework,版本5.0.0.0 =文化=中性公钥= b77a5c561934e089'在位置上下文'默认'C:\Windows\Microsoft.NET\Framework\v4.0.30319\\ \\Temporary ASP.NET Files\project211ef\97babe28\e7ea3fa9\assembly\dl3\01275099\70646f08_d86ecf01\EntityFramework.dll。B型从起源'的EntityFramework,版本6.0.0.0 =文化=中性公钥= b77a5c561934e089'的背景下,'在位置'C默认值:\Projects\project\2.1.1EF2\packages\EntityFramework.6.1.0\lib\\\
et45\EntityFramework.dll。 }
{"[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'."}
它看起来像它仍然试图用EF5,尽管它访问EF6实体部分。
It looks like it's still trying to use EF5, despite it accessing the EF6 entity section.
我通过添加绑定重定向解决了这个问题。在主的web.config
我重定向到新的版本,然后在子的web.config
重定向到旧版本
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.
推荐答案
这是可以通过定义组件配置文件结合使用相同的应用程序两个不同版本装配。我觉得这回答应该帮助你。
It's possible to use two different versions of assembly in the same applications by defining assembly binding in config file. I think this answer should help you.
这篇关于不同的EntityFramework版本相同的解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!