Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add-Migration command only prompt "ScriptHalted"

I'm trying to learn how to make App.Net Core application using Razor pages, using this tutorial : https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/model?view=aspnetcore-3.0&tabs=visual-studio

After I made the Movie model and scaffold it successfully, I try to make the initial migration of the database.

However, every time I'm using the command Add-Migration, it just prompts ScriptHalted, even when using the verbose option, same with Update-Database.

I tried other commands like Enable-Migration and they seems to work, but not the two I need.

Is there anything that I'm missing ?

It seems to me that I followed the tutorial perfectly, and tried to find an answer here, yet I didn't come up with any solutions.

like image 686
PepperTiger Avatar asked Oct 15 '22 09:10

PepperTiger


2 Answers

I found the answer in a closed question of the english tutorial page (I was using the french one at first)

https://developercommunity.visualstudio.com/content/problem/753703/package-manager-console-scripthalted.html

In simple, the error was coming from an older version of PowerShell that Windows 7 use. Updating it seems to work now.

like image 97
PepperTiger Avatar answered Oct 18 '22 05:10

PepperTiger


The problem is the version of powershell.

powershell on win7 is 2.0,and PM is base on powershell.so,after i upgrade my powershell version to 5.1 ,it work out.

here you can look at version https://learn.microsoft.com/zh-cn/powershell/scripting/install/installing-windows-powershell?view=powershell-6

and what i download is here https://www.microsoft.com/en-us/download/details.aspx?id=54616

like image 38
Rupesh Avatar answered Oct 18 '22 04:10

Rupesh