问题
I'm trying to learn how to make App.Net Core application using Razor pages, using this tutorial : https://docs.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.
回答1:
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.
回答2:
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://docs.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
回答3:
I came across this error today. As others had said it's about upgrading the Powershell on a Windows 7 machine. Here is the link that has worked for me.
https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/wmf/setup/install-configure?view=powershell-7.1
After restarting the PC, the update-database worked as expected.
来源:https://stackoverflow.com/questions/58643426/add-migration-command-only-prompt-scripthalted