Add-Migration command only prompt “ScriptHalted”

巧了我就是萌 提交于 2021-02-16 16:31:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!