2013-01-19 28 views
13

Sono nuovo di MVC 4 e Entity Framework e quando corro questo comando dalla console di gestione dei pacchetti:Entity Codice Framework prima migrazione errore

Enable-Migrations -ContextTypeName MyFirstMvcApp.Models.InventoryDbContext 

Join-Path: Impossibile associare argomento al parametro 'Percorso' perché è nullo.

ottengo il seguente errore:

Join-Path : Cannot bind argument to parameter 'Path' because it is null. 
At D:\GitProjects\MyFirstMvcApp\trunk\packages\EntityFramework.6.0.0-alpha2\tools\EntityFramework.psm1:363 char:27 
+  $toolsPath = Join-Path <<<< $installPath tools 
    + CategoryInfo   : InvalidData: (:) [Join-Path], ParameterBindingValidationException 
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand 

Join-Path : Cannot bind argument to parameter 'Path' because it is null. 
At D:\GitProjects\MyFirstMvcApp\trunk\packages\EntityFramework.6.0.0-alpha2\tools\EntityFramework.psm1:392 char:73 
+  $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path <<<< $toolsPath EntityFramework.PowerShell.Utility.dll)) 
    + CategoryInfo   : InvalidData: (:) [Join-Path], ParameterBindingValidationException 
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand 

You cannot call a method on a null-valued expression. 
At D:\GitProjects\MyFirstMvcApp\trunk\packages\EntityFramework.6.0.0-alpha2\tools\EntityFramework.psm1:393 char:50 
+  $dispatcher = $utilityAssembly.CreateInstance <<<< (
    + CategoryInfo   : InvalidOperation: (CreateInstance:String) [], RuntimeException 
    + FullyQualifiedErrorId : InvokeMethodOnNull 

Join-Path : Cannot bind argument to parameter 'Path' because it is null. 
At D:\GitProjects\MyFirstMvcApp\trunk\packages\EntityFramework.6.0.0-alpha2\tools\EntityFramework.psm1:426 char:19 
+   (Join-Path <<<< $runner.ToolsPath EntityFramework.PowerShell.dll), 
    + CategoryInfo   : InvalidData: (:) [Join-Path], ParameterBindingValidationException 
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand 

Come posso risolvere questo problema? Nota che sto utilizzando Visual Studio 2010 Ultimate con SP1 e che ho installato MVC4 in questo link.

risposta

28

Risolto il problema disinstallando e reinstallando il framework entità. Per il bene degli altri, qui ci sono i comandi ...

disinstallazione:

PM> Uninstall-Package EntityFramework -Force

Dopo la disinstallazione, reinstallare EntityFramework:

PM> Install-Package EntityFramework -Pre

C'è! È sistemato. Anche se non so ancora cosa ha causato il problema.

+1

'PM> Installa-Package EntityFramework -Pre -Version 5.0.0' per specifica versione – nicemd

+0

qualche commento: Devi eseguire il VS in modalità "come amministratore" –

+0

Questo ha funzionato anche per me, grazie! –

1

La disinstallazione di Entity Framework non ha funzionato per me.

Si è scoperto che non era Visual Studio o Entity Framemwork casuing il problema, ma è stato il fatto che io correvo PowerShell 2 (su Windows 7).

Entity Framework e Visual Studio richiedono PowerShell 3.

Dopo l'aggiornamento e il riavvio, il problema era scomparso. Speriamo che questo aiuti alcune persone.

Potete trovare PowerShell qui ->https://www.microsoft.com/en-us/download/details.aspx?id=40855

0

Nel mio caso nessuna delle soluzioni indicate funziona, così ho avuto un rapido sguardo nel file packages.config e con mia sorpresa ha trovato due voci per Entity Framework

<package id="EntityFramework" version="6.1.1" targetFramework="net45" /> 
<package id="EntityFramework" version="6.1.3" targetFramework="net45" /> 

Si noti che sono versioni diverse, non sono sicuro di come ciò potrebbe effettivamente accadere. Ad ogni modo, una volta che ho rimosso il più vecchio dal file packages.config cioè finito con solo questo:

<package id="EntityFramework" version="6.1.3" targetFramework="net45" /> 

ho potuto quindi Enable-Migrazioni senza problemi.

Problemi correlati