2013-01-19 2 views
13

Ich bin neu auf MVC 4 und Entity Framework und wenn ich diesen Befehl aus dem Paket-Manager-Konsole:Entity Framework-Code Erste Migration Fehler

Enable-Migrations -ContextTypeName MyFirstMvcApp.Models.InventoryDbContext 

Join-Path: Kann nicht Argument binden in den Parameter 'Pfad' weil es null ist.

bekomme ich folgende Fehlermeldung:

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 

Wie kann ich dieses Problem beheben? Beachten Sie, dass ich Visual Studio 2010 Ultimate mit SP1 verwende und MVC4 in diesem link installiert habe.

Antwort

28

Es wurde durch die Deinstallation und Neuinstallation von Entity Framework behoben. Zum Wohle der anderen, hier sind die Befehle ...

Deinstallation:

PM> Uninstall-Package EntityFramework -Force

Nach der Deinstallation neu installieren EntityFramework:

PM> Install-Package EntityFramework -Pre

There! Es ist repariert. Obwohl ich immer noch nicht weiß, was das Problem verursacht hat.

+1

'PM> Install-Package EntityFramework -Pre -Version 5.0.0' für bestimmte Version – nicemd

+0

etwas Kommentar: Sie müssen Ihre VS in "als Administrator" –

+0

Auch das für mich gearbeitet, dank laufen! –

1

Deinstallieren von Entity Framework hat nicht für mich funktioniert.

Es stellte sich heraus, dass es nicht Visual Studio oder Entity Framemwork casuing das Problem war, aber es war die Tatsache, dass ich PowerShell 2 (auf Windows 7) ausgeführt wurde.

Entity Framework und Visual Studio erfordern PowerShell 3.

Nach dem Update und Neustart war das Problem verschwunden. Hoffentlich hilft das ein paar Leute.

können Sie Powershell finden Sie hier ->https://www.microsoft.com/en-us/download/details.aspx?id=40855

0

In meinem Fall keine der oben genannten Lösungen gearbeitet, so hatte ich einen kurzen Blick in die packages.config Datei und zu meiner Überraschung zwei Einträge gefunden für Entity Framework

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

Beachten Sie, dass sie verschiedene Versionen sind, nicht sicher, wie dies tatsächlich passieren könnte. Wie auch immer, einmal nahm ich die ältere aus der packages.config Datei heißt mit nur diesem einen endete:

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

konnte ich dann ohne Probleme Enable-Migrationen.