在急忙升级到EF 5.0.0.0 RC并且无法部署到Windows Azure(.NET 4.0及更低版本)的.NET 4.5项目之后,我决定降级到EF 4.3.1.0.
我不确定执行此类迁移的最佳方法,但我的策略是使用"管理NuGet包"识别哪些项目引用包,取消选中每个项目的包,安装替换并重新检查正确的项目.
不幸的是,在这样做之后,我的解决方案产生了名为"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)
Run Code Online (Sandbox Code Playgroud)
我搜索了解决方案文件,特别是packages.config,以获取对EF 5.0.0.0 RC的引用但却找不到.
Daz*_*kin 42
尝试在repositories.config和其他地方找到对EntityFramework的引用失败后,我偶然发现了Web.config中的引用,因为我正在编辑它以帮助我进行诊断.
bindingRedirect引用了不再安装的5.0.0.0,这似乎是异常的来源.老实说,我没有添加对Web.config的引用,并且在尝试在单独的项目中复制错误之后,发现NuGet包安装程序没有添加它,所以,我不知道为什么它在那里但添加了一些东西它.
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
我决定用工作项目中的等效元素替换它.注意,对5.0.0.0的引用将替换为以下4.3.1.0:
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
</dependentAssembly>
Run Code Online (Sandbox Code Playgroud)
这有效!
然后我决定完整地删除EntityFramework的dependentAssembly引用.
它仍然有效!
所以,我在这里发布这个作为一个自我回答的问题,希望它能帮助别人.如果有人能向我解释:
我有兴趣学习.
The*_*ear 19
我有这个问题,我所做的只是确保我在所有项目中引用了正确的.Net框架然后只需更改web.config
从
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
Run Code Online (Sandbox Code Playgroud)
至
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework" requirePermission="false"/>
Run Code Online (Sandbox Code Playgroud)
所有作品..
更新旧项目时遇到了同样的问题.这是我做的解决方法:
使用Entity Framework 5和.NET 4的项目正在安装Entity Framework dll版本4.4.一旦我在项目上将.NET版本切换到4.5,dll版本就是5.
我的问题来自.NET 4上的旧项目和运行.NET 4.5的新项目,所以我的解决方案中有2个dll版本的EF.
希望这有助于某人......