Search code examples
c#entity-frameworkasp.net-mvc-4powershellvisual-studio-2013

EntityFramework.6.1.2-beta1\tools\init.ps1 is restricted, cannot run enable-migrations Command


Visual Studio 2013 C# ASP.NET MVC problem EntityFramework.6.1.2-beta1\tools\init.ps1 cannot be loaded because its execution is blocked by software restriction policies. For more information, contact your system administrator.

When I try to use the Enable-Migrations: I get the message below: The term 'Enable-Migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spe lling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:18 + Enable-Migrations <<<< + CategoryInfo : ObjectNotFound: (Enable-Migrations:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

I have the above Issue, and I tried all sorts of solutions for it, but none of them helped

Things that I have already done:

  1. removed all nuget extention and installed it Again (Didn't Work)
  2. Removed Entity Framework and reinstalled it again (Didn't Work)
  3. closed my visual studio 2013 and reopened the file (Didn't Work)
  4. Opened visual studio using Administrator (Didn't Work)
  5. Deleted the whole package brought package from a different project (Didn't Work)

I even tried some power shell commands, still does not work.


Solution

  • I found the solution to my problem. The reason was that, my user-profile was somehow blocking me from running the init.ps1 file of EntityFramework. I created a new user profile, with admin rights, and Ran Visual Studio on that profile, and now the EntityFramework, works perfectly. Incase if you have the same problem, try the above, stuff that I have already tried, and if none of them work, then try this..

    Good Luck