2015-05-09 31 views
10

Tôi có một số tệp lớp. Nhưng bây giờ tôi đã thêm lớp mô hình mới và đã cố gắng gõ thêm di trú InitialCreate. Nhưng tôi nhận được lỗi sau.Lỗi trong 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> 

Trả lời

12

Sử dụng Package Manager, bạn cần phải cài đặt lại Entity Framework:

Uninstall-Package EntityFramework -force

Sau đó cài đặt nó cho từng dự án:

Gói cài đặt EntityFramework

Sau đó đừng quên khởi động lại studio.

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

1

Tôi đã có một trường hợp hơi khác nhau ngày hôm nay, tôi đang wirting chi tiết tại đây trong trường hợp đó có thể giúp ai đó. Các lỗi đã được tham khảo một trong những hội đồng của tôi thay vào đó, trên đó lắp ráp có chứa EF DbContext là tùy thuộc.
Tôi đã giải quyết nó cài đặt assembly được tham chiếu thành "Copy Local" "true" để nó tạo một bản sao cục bộ khi xây dựng để di chuyển và do đó có thể tìm thấy nó.

1

bạn cần phải cài đặt lại Khuôn khổ thực thể:

Các vấn đề liên quan