2012-03-05 128 views
4

我遇到EF迁移问题,特别是使“Enable-Migrations”命令正常工作。当我在包管理器控制台执行命令我收到以下错误:实体框架迁移问题

System.Management.Automation.PSArgumentException: Cannot find type System.Data.Entity.Migrations.MigrationsCommands]: make sure the assembly containing this type is loaded.
at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
Cannot find type [System.Data.Entity.Migrations.MigrationsCommands]: make sure the assembly containing this type is loaded.

在我看来,该控制台的NuGet找不到MigrationsCommands从我的EF组装式。我已经检查过,程序集是最近的一个(4.3.1),并且在对象浏览器中我无法找到MigrationsCommands类型或名称空间。

更新:我仍然没有解决方法,但在Package Manager控制台中运行“Install-Package EntityFramework”命令时,问题的来源看起来像下面的输出。该错误是在这里:

Unable to find type [ConnectionFactoryConfiguratorInvoker]: make sure that the assembly containing this type is loaded. 
At C:\...\packages\EntityFramework.4.3.1\tools\install.ps1:36 char:39 
+ [ConnectionFactoryConfiguratorInvoker] <<<< ::Invoke((Join-Path $toolsPath "EntityFramework.PowerShell.dll"), $project) 
+ CategoryInfo   : InvalidOperation: (ConnectionFactoryConfiguratorInvoker:String) [], RuntimeException 
+ FullyQualifiedErrorId : TypeNotFound 
+0

您的解决方案中有多少个项目? – 2012-03-06 09:33:05

+0

由于这是一个虚拟测试项目,我有两个项目,它们都引用EF(控制台测试工具和带有dbcontext和域的项目)。我已经尝试将包管理器控制台指向两个项目。 – jdscolam 2012-03-06 15:09:43

+0

拉迪斯拉夫,感谢您的评论。我已经发布了下面的答案。 – jdscolam 2012-03-07 20:22:35

回答

2

几个小时的搜索后,我已经找到了解决办法。他们的钥匙位于菲尔·哈克对反射器6.5的“克里斯”的回应中,位于Here。我安装了Reflector(版本7.0足够好奇),并且在VS2010中启用了Reflector Add-On。在研究NuGet FAQ后,我卸载了Reflector并禁用了VS2010加载项。这似乎已经解决了这个问题,因为我现在可以同时安装“Install-Package EntityFramework”和“Enable-Migrations”。

0

禁用外接内VS2010 (工具 - 选项 - 环境 - 加载项/宏安全性/允许外接组件LAOD) 如果安装中VS2010 (工具 - 选项 - ReSharper-禁用ReSharper的暂停)

重启VS2010,问题就解决了。

+0

Zork,我已经启用了Resharper并且没有问题。该问题看来是专门用反射器而不是Resharper。 – jdscolam 2012-03-08 15:08:07