Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error creating new MVC project - EF and JQuery

Tags:

Whenever I create a new MVC project, I am getting an error - failed to initialize Powershell host, for the entity framework and Jquery. The error: The following packages failed to install from 'C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 4\Packages'

EntityFramework.5.0.0: Failed to initialize the Powershell host. If your powershell execution policy setting is set to AllSigned, open the package manager console to initialize the host first.

jQuery.1.7.1.1: Failed to initialize the Powershell host. If your powershell execution policy setting is set to AllSigned, open the package manager console to initialize the host first.

I can remove the Entity Framework reference, and add it manually, which is a good workaround, but it is annoying and a sign of some problem somewhere. Any ideas where to look?

This link documents a similar problem and workaround: http://social.msdn.microsoft.com/Forums/en/vssetup/thread/c934fed4-e44e-4a06-9e3b-eccb9c8aa8d6

like image 238
aSkywalker Avatar asked Jan 26 '13 15:01

aSkywalker


People also ask

How can add Entity Framework in ASP NET MVC?

Step2: Adding ADO.NET Entity Data Model in ASP.NET MVC Application. Right-Click on Models Folder, and then select Add => New Item from the context menu which will open the Add New Item window. From the “Add New Item” window, from the left pane expand Installed => Visual C# => Data option.

What is @model in Cshtml?

The @model directive allows access to the list of movies that the controller passed to the view by using a Model object that's strongly typed. For example, in the Index.cshtml view, the code loops through the movies with a foreach statement over the strongly typed Model object: CSHTML Copy.

Which command of EF core in MVC application will create the context classes for application data model?

Create the database context The main class that coordinates EF functionality for a given data model is the DbContext database context class. This class is created by deriving from the Microsoft. EntityFrameworkCore. DbContext class.


2 Answers

One of the replies on the MSDN thread worked for me. Run PowerShell as an Administrator and run the following command:

Set-ExecutionPolicy AllSigned 

See Using the Set-ExecutionPolicy Cmdlet for security implications.

like image 81
jrummell Avatar answered Oct 08 '22 18:10

jrummell


This problem is fairly common - as there are multiple links to the MSDN forums and references to the workaround. I tried troubleshooting with the Package Manager in Visual Studio and noticed that it was frozen - with a reference to looking for C:\Program Files (x86)\7-Zip\7z.exe. No idea why, but I checked my system and sure enough, I have 7z installed in the standard Program Files (not x86). I made a copy in the x86 folder, reloaded Visual Studio and Visual Studio is now happy again. Not sure why there is a dependancy on 7zip in the Visual Studio Package Manager - but hopefully this will help another programmer ...

like image 41
aSkywalker Avatar answered Oct 08 '22 19:10

aSkywalker