VS 2015 (RC)下Entitiy Framework 升級后CodeFirst命令不能使用


前陣子閑的沒事吧自己項目的Entitiy Framework 升級到6.1.3了,然后緊接着問題來了:

Join-Path : 無法將參數綁定到參數“Path”,因為該參數是空值。
所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:740 字符: 27
+     $toolsPath = Join-Path <<<<  $installPath tools
    + CategoryInfo          : InvalidData: (:) [Join-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
 
Join-Path : 無法將參數綁定到參數“Path”,因為該參數是空值。
所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 字符: 73
+     $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path <<<<  $ToolsPath EntityFramework.PowerShell.Utility.dll))
    + CategoryInfo          : InvalidData: (:) [Join-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
 
不能對值為空的表達式調用方法。
所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:781 字符: 50
+     $dispatcher = $utilityAssembly.CreateInstance <<<< (
    + CategoryInfo          : InvalidOperation: (CreateInstance:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
Join-Path : 無法將參數綁定到參數“Path”,因為該參數是空值。
所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:810 字符: 19
+         (Join-Path <<<<  $runner.ToolsPath EntityFramework.PowerShell.dll),
    + CategoryInfo          : InvalidData: (:) [Join-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
 
Join-Path : 無法將參數綁定到參數“Path”,因為該參數是空值。
所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:740 字符: 27
+     $toolsPath = Join-Path <<<<  $installPath tools
    + CategoryInfo          : InvalidData: (:) [Join-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
 
Join-Path : 無法將參數綁定到參數“Path”,因為該參數是空值。
所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 字符: 73
+     $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path <<<<  $ToolsPath EntityFramework.PowerShell.Utility.dll))
    + CategoryInfo          : InvalidData: (:) [Join-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
 
不能對值為空的表達式調用方法。
所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:781 字符: 50
+     $dispatcher = $utilityAssembly.CreateInstance <<<< (
    + CategoryInfo          : InvalidOperation: (CreateInstance:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
Join-Path : 無法將參數綁定到參數“Path”,因為該參數是空值。
所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:810 字符: 19
+         (Join-Path <<<<  $runner.ToolsPath EntityFramework.PowerShell.dll),
    + CategoryInfo          : InvalidData: (:) [Join-Path], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
 

一大堆的亂起八糟的,開始以為是Entitiy Framework版本問題或者是VS的問題,各種亂試都沒能成功。

無奈只得翻牆GOOGLE了最后得到的結論是:跟Entitiy Framework的版本以及VS都無關是PowerShell的版本問題,

查了下我機器上是2.0版本的

PS C:\Users\PC> $PSVersionTable.PSVersion

Major Minor Build Revision
----- ----- ----- --------
2 0 -1 -1

於是想法升級(我的版本選擇錯誤,這是個4。0的版本建議升級3.0試試能夠成功解決)

Windows Management Framework 4.0

下載地址

https://www.microsoft.com/zh-CN/download/details.aspx?id=40855

我系統是win7 於是下載了 Windows6.1-KB2819745-x64-MultiPkg.msu

悲劇的事這個PowerShell居然是4.0版本的升級過頭了出現了新問題:

New-Object : 提供的值無效或屬性是只讀的。請更改該值,然后再試一次。所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:757 字符: 13
+     $info = New-Object System.AppDomainSetup -Property @{
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [New-Object],Exception
    + FullyQualifiedErrorId : SetValueException,Microsoft.PowerShell.Commands.NewObjectCommand
 
在此對象上找不到屬性“PrivateBinPath”。請確認該屬性存在並且可設置。所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:772 字符: 9
+         $info.PrivateBinPath += ';lib\net45'
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [],RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound
 
使用“1”個參數調用“LoadFrom”時發生異常:“指定的路徑或文件名太長,或者兩者都太長。完全限定文件名必須少於 260 個字符,並且目錄名必須少於 248 個字符。”所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\tools\Entit
yFramework.psm1:780 字符: 5
+     $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path $ToolsP ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : PathTooLongException
 
不能對 Null 值表達式調用方法。所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:781 字符: 5
+     $dispatcher = $utilityAssembly.CreateInstance(
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [],RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
 
使用“8”個參數調用“CreateInstanceFrom”時發生異常:“指定的路徑或文件名太長,或者兩者都太長。完全限定文件名必須少於 260 個字符,並且目錄名必須少於 248 個字符。”所在位置 F:\Source\WebSolution\packages\EntityFramework.6.1.3\t
ools\EntityFramework.psm1:809 字符: 5
+     $domain.CreateInstanceFrom(
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : PathTooLongException
 

無奈繼續求助GOOGLE吧

得到的結論很多有替換EntityFramework.psm1文件,有升級Nuget。

https://github.com/aspnet/EntityFramework/issues/1950#issuecomment-99164398

只得替換EntityFramework.psm1好些沒啥效果

最終選擇了升級NuGet 3.0 RC2

成功解決!

走了很多彎路,也不知道是不是最正確的解決版本,希望能給遇到同樣問題的有所幫助吧。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM