2015-05-09 14 views
10

Ich habe mehrere Klassen-Dateien. Aber jetzt bin ich neue Model-Klasse hinzugefügt und habe versucht, Add-Migration InitialCreate eingeben. Aber ich erhalte den folgenden Fehler.Fehler in ef Add-Migration

PM> add-migration InitialCreate 
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\Users\user\Documents\Visual Studio 2013\Pro 
jects\DigitalHealthWebPrev\packages\EntityFramework.6.1.3\tools\EntityFramework.PowerShell.Utility.dll' or one of its dependencies. Operati 
on is not supported. (Exception from HRESULT: 0x80131515)" 
At C:\Users\user\Documents\Visual Studio 2013\Projects\DigitalHealthWebPrev\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 c 
har:62 
+  $utilityAssembly = [System.Reflection.Assembly]::LoadFrom <<<< ((Join-Path $ToolsPath EntityFramework.PowerShell.Utility.dll)) 
    + CategoryInfo   : NotSpecified: (:) [], MethodInvocationException 
    + FullyQualifiedErrorId : DotNetMethodException 

You cannot call a method on a null-valued expression. 
At C:\Users\user\Documents\Visual Studio 2013\Projects\DigitalHealthWebPrev\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:781 c 
har:50 
+  $dispatcher = $utilityAssembly.CreateInstance <<<< (
    + CategoryInfo   : InvalidOperation: (CreateInstance:String) [], RuntimeException 
    + FullyQualifiedErrorId : InvokeMethodOnNull 

Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'file:///C:\Users\user\Documents\Visual Studi 
o 2013\Projects\DigitalHealthWebPrev\packages\EntityFramework.6.1.3\tools\EntityFramework.PowerShell.dll' or one of its dependencies. Opera 
tion is not supported. (Exception from HRESULT: 0x80131515)" 
At C:\Users\user\Documents\Visual Studio 2013\Projects\DigitalHealthWebPrev\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:809 c 
har:31 
+  $domain.CreateInstanceFrom <<<< (
    + CategoryInfo   : NotSpecified: (:) [], MethodInvocationException 
    + FullyQualifiedErrorId : DotNetMethodException 

PM> 

Antwort

12

den Package Manager verwenden, müssen Sie Entity Framework neu installieren:

Uninstall-Paket EntityFramework -Force

Dann installieren Sie es für jedes Projekt:

Install-Paket EntityFramework

Dann vergessen Sie nicht, das Studio neu zu starten.

https://stackoverflow.com/a/14994432/1845408

1

hatte ich einen etwas anderen Fall heute, ich bin wirting die hier Details in dem Fall, dass jemand helfen könnte. Der Fehler bezog sich stattdessen auf eine meiner Assemblys, auf die die Assembly mit dem EF DbContext angewiesen war.
Ich löste es, indem ich die referenzierte Assembly auf "Copy Local" "true" einstellte, damit es beim Erstellen von Migrationen eine lokale Kopie erstellen und sie daher finden konnte.

1

Sie müssen Entity Framework neu installieren: