2015-09-07 64 views
1

我想使用Android/iOS可以使用的Web服務在Angular中構建網站。我終於找到了一個很棒的教程,幫助我設置了這個教程。下一步是擴展身份模型。所以,我添加了一個屬性。然後,我開始得到一個異常:。當模型發生變化時,WebAPI 2中的EF標識停止工作

「的模式支持了‘AuthContext’語境自創建數據庫時改變考慮使用代碼首先遷移到更新數據庫(http://go.microsoft.com/fwlink/?LinkId=238269

所以,當我遵守這些指示,我得到這個:

Enable-Migrations 
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\copa\AngularJSAuthentication-master\packages\EntityFramework.6.1.0\tools\EntityFramework.PowerShell. 
Utility.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)" 
At C:\copa\AngularJSAuthentication-master\packages\EntityFramework.6.1.0\tools\EntityFramework.psm1:780 char: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:\copa\AngularJSAuthentication-master\packages\EntityFramework.6.1.0\tools\EntityFramework.psm1:781 char: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:\copa\AngularJSAuthentication-master\packages\EntityFramework.6.1.0\tools\EntityFramework.P 
owerShell.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)" 
At C:\copa\AngularJSAuthentication-master\packages\EntityFramework.6.1.0\tools\EntityFramework.psm1:809 char:31 
+  $domain.CreateInstanceFrom <<<< (
    + CategoryInfo   : NotSpecified: (:) [], MethodInvocationException 
    + FullyQualifiedErrorId : DotNetMethodException 

PM> Enable-Migrations -ContextTypeName AngularJSAuthentication.API.AuthContext 
The project 'AngularJSAuthentication.API' failed to build. 
PM> Enable-Migrations -ContextTypeName AngularJSAuthentication.API.AuthContext 
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\copa\AngularJSAuthentication-master\packages\EntityFramework.6.1.0\tools\EntityFramework.PowerShell. 
Utility.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)" 
At C:\copa\AngularJSAuthentication-master\packages\EntityFramework.6.1.0\tools\EntityFramework.psm1:780 char: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:\copa\AngularJSAuthentication-master\packages\EntityFramework.6.1.0\tools\EntityFramework.psm1:781 char: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:\copa\AngularJSAuthentication-master\packages\EntityFramework.6.1.0\tools\EntityFramework.P 
owerShell.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)" 
At C:\copa\AngularJSAuthentication-master\packages\EntityFramework.6.1.0\tools\EntityFramework.psm1:809 char:31 
+  $domain.CreateInstanceFrom <<<< (
    + CategoryInfo   : NotSpecified: (:) [], MethodInvocationException 
    + FullyQualifiedErrorId : DotNetMethodException 

PM> Enable-Migrations 
Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:\copa\AngularJSAuthentication-master\packages\EntityFramework.6.1.0\tools\EntityFramework.PowerShell. 
Utility.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)" 
At C:\copa\AngularJSAuthentication-master\packages\EntityFramework.6.1.0\tools\EntityFramework.psm1:780 char:62 
+  $utilityAssembly = [System.Reflection.Assembly]::LoadFrom <<<< ((Join-Path $ToolsPath EntityFramework.PowerShell.Utility.dll)) 
    + CategoryInfo   : NotSpecified: (:) [], MethodInvocationException 
    + FullyQualifiedErrorId : DotNetMethodException 

我已經改變了我的初始化器在啓動(註釋表明它是什麼)

Database.SetInitializer<AuthContext>(null);// <AuthContext>());//, AngularJSAuthentication.API.Migrations.Configuration>()); 

並在上下文類靜態構造函數(這個組合是我在另一個項目中所做的那樣)

static AuthContext() 
    { 
     Database.SetInitializer<AuthContext>(new AuthContextInitialiser()); 
    } 

我很茫然,我GOOGLE了,但我看到的解決方案,不似乎工作。 VS正在以管理員身份運行。我只是想EF不關心我的數據庫,並相信我,它應該是這樣...

其實,如果我告訴它取代我的數據庫(我不喜歡),我得到這個錯誤:

Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration 

沒有,只是留下我一個人相信我能管理自己的數據庫路徑...

感謝

+0

有人可以告訴我,我」米做錯了嗎?沒有人回答我.... – cgraus

回答

0

此異常和HResult的代碼來,如果有一個安全限制防止組件被加載。

的常見原因:

  • 網絡共享或驅動器:將文件複製到硬盤
  • DLL從其他機器複製:右鍵單擊並解鎖
相關問題