1

我在 Entity Framework 中的模型中添加了两列,并将一个字段从字符串更改为枚举。当我转到包管理器控制台并输入“更新数据库”时,我收到以下错误:

System.Runtime.Serialization.SerializationException: Type is not resolved for member 'System.Data.Entity.Migrations.Design.ToolingFacade+UpdateRunner,EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
   at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
   at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
   at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
   at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Type is not resolved for member 'System.Data.Entity.Migrations.Design.ToolingFacade+UpdateRunner,EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

我在启用迁移时遇到同样的错误。

我看到一个问题建议摆脱 __Migrations 表,我这样做了,但它似乎没有帮助。

另一个解决方案建议将项目更改为 .NET 4.5,然后重新安装 EF 5,我这样做了,但所做的只是更改错误中的 EF 版本号。

有任何想法吗?

4

2 回答 2

1

修复了这个问题;必须从文件路径中删除 & 符号 (!!!!)

于 2013-07-16T20:01:48.137 回答
0

我遇到了同样的问题,结果证明是由解决方案中的两个项目使用不同版本的 EntityFramework 引起的。我的代码优先对象是在他们自己的 .NET Framework 4.0 程序集中构建的,但该解决方案的启动项目是一个 .NET 4.5 MVC 项目。尽管两个项目都使用实体框架“5.0”,但 .NET 4 版本的 EF5 是不同的程序集(版本 4.4)。

我发现允许“更新数据库”命令工作的临时修复是更改 Web.config 文件中的此部分:

  <dependentAssembly>
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
  </dependentAssembly>

对此:

  <dependentAssembly>
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-4.4.0.0" newVersion="4.4.0.0"/>
  </dependentAssembly>

我的最终解决方法是使用我的代码第一类将程序集更新到 .NET 4.5 并重新安装 EF5。

于 2014-01-12T06:54:39.107 回答