ASP.NET MVC Nuget Enabling-Migrations

2

I am learning about ASP.NET MVC5 with Entity Framework. For my learning I'm using Lynda Video tutorials and I am stuck at the Nuget Console where I have to run the following code:

Enable-Migrations -ContextType ApplicationDbContext

After i run it I got the folowin error:

Enable-Migrations -ContextType ApplicationDbContext Exception calling "LoadFrom" with "1" argument(s): "Could not load file or assembly 'file:///C:...\Projects\Lynda MVC - Exercise Files\Ch3 - continue\Start\packages\EntityFramework.6.1.1\tools\EntityFramework.PowerShell.Utility.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)" At C:...\Projects\Lynda MVC - Exercise Files\Ch3 - continue\Start\packages\EntityFramework.6.1.1\tools\EntityFramework.psm1:780 char:5 + $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path $ToolsP ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : FileLoadException You cannot call a method on a null-valued expression. At C:...\Projects\Lynda MVC - Exercise Files\Ch3 - continue\Start\packages\EntityFramework.6.1.1\tools\EntityFramework.psm1:781 char:5 + $dispatcher = $utilityAssembly.CreateInstance( + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull Exception calling "CreateInstanceFrom" with "8" argument(s): "Could not load file or assembly 'file:///C:...\Projects\Lynda MVC - Exercise Files\Ch3 - continue\Start\packages\EntityFramework.6.1.1\tools\EntityFramework.PowerShell.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)" At C:...\Projects\Lynda MVC - Exercise Files\Ch3 - continue\Start\packages\EntityFramework.6.1.1\tools\EntityFramework.psm1:809 char:5 + $domain.CreateInstanceFrom( + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : FileLoadException

If you can help me with any solution it will be a big help.

asp.net
asp.net-mvc
entity-framework
asp.net-mvc-4
nuget
asked on Stack Overflow Nov 26, 2014 by Acnologia • edited Nov 26, 2014 by ROMANIA_engineer

2 Answers

3

Use '-ContextTypeNameswitch instead, and specify yourDBContext` class. i.e,

Enable-Migrations -ContextTypeName Someproject.DepartmentDb

For more useful switches, refer THIS

answered on Stack Overflow Nov 26, 2014 by Zeeshan
1

I had the same problem. My project was stored in a network drive. There are many security policies applied to my PC. I moved my project to the local hard drive, and the problem was solved.

It seems like "EntityFramework.Powershell.utility.dll" is tring to use some powershell functionality, and the system is preventing to execute such calls, maybe because the dll that is calling powershell is not a local file.

In your case, make sure that you do not have any security policy or system configuration that would prevent your system to call to the problematical extension (EntityFramework.Powershell.utility.dll).

answered on Stack Overflow May 26, 2015 by Rafa Sanchez

User contributions licensed under CC BY-SA 3.0