2012-03-05 248 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