I want to build a website in Angular with a web service that Android/iOS can use. I finally found a great tutorial that helped me set that up. The next step, is to extend the Identity Model. So, I added a property. Then I started to get an exception:
"The model backing the 'AuthContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
So, when I follow those instructions, I get this:
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
I've changed my initialiser in Startup ( commented shows what it was )
Database.SetInitializer<AuthContext>(null);// <AuthContext>());//, AngularJSAuthentication.API.Migrations.Configuration>());
and in a static constructor in the context class ( this combination is what i did in another project )
static AuthContext()
{
Database.SetInitializer<AuthContext>(new AuthContextInitialiser());
}
I am at a loss, I've googled, but the solutions I see, don't seem to work. VS is running as admin. I just want EF to not care about my DB, and to trust me that it's the way it should be....
Actually, if I tell it to replace my DB ( which I don't like ), I get this error:
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
There is no path that just leaves me alone and trusts me to manage my own DB...
Thanks
This exception and HResult code comes if there's a security restriction preventing the assemblies to be loaded.
Typical causes:
User contributions licensed under CC BY-SA 3.0