我正在尝试计算entity framework
教程“ Creating a Model for an Existing Database in Entity Framework Core // entityframeworktutorial.net”-
当我输入命令时:PM> Scaffold-DbContext" Server =. \ SQLEXPRESS1; Database = SCHOOLDB.MDF; Trusted_Connection = True; " Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
我收到错误消息:ScriptHalted
使用者:
-Visual Studio-2019.社区-16.3.6;
-控制台应用程序。核心3.0;
-Microsoft.EntityFrameworkCore-3.0.0;
-Microsoft.EntityFrameworkCore.Tools-3.0.0;
故事:
-我安装了“ Microsoft.EntityFrameworkCore-3.0.0;”
-我运行命令:PM> Scaffold-DbContext" Server =. \ SQLEXPRESS1; Database = SCHOOLDB.MDF; Trusted_Connection = True; " Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
-我收到一个错误:
The name" Scaffold-DbContext "is not recognized as the name of the cmdlet, function, script file, or executable program. Check for correctness.
spelling of the name, as well as the presence and correctness of the path, then try again.
line: 1 character: 19
+ Scaffold-DbContext <<<< "Server =. \ SQLEXPRESS1; Database = SCHOOLDB.MDF; Trusted_Connection = True;" Microsoft.EntityFrameworkCore.SqlSe
rver -OutputDir Models
+ CategoryInfo: ObjectNotFound: (Scaffold-DbContext: String) [], CommandNotFoundException
+ FullyQualifiedErrorId: CommandNotFoundException
-我安装了Microsoft.EntityFrameworkCore.Tools
(根据建议-“ Scaffold-DbContext 'is not recognized -> require EF Tools // github.com”)`
-我运行以下命令:PM> Scaffold-DbContext" Server =. \ SQLEXPRESS1; Database = SCHOOLDB.MDF; Trusted_Connection = True; " Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
-我收到错误消息:ScriptHalted
问题。
如何解决“ ScriptHalted”错误?
答案 0 :(得分:2)
我今天遇到了同样的问题,我使用的是Windows7。Windows7使用的是powershell 2.0,因此我将其升级到了5.1,您可以从此处进行升级-https://docs.microsoft.com/en-us/powershell/scripting/install/installing-windows-powershell?view=powershell-6
升级此解决了我的问题。我从这里找到了这个解决方案-https://github.com/aspnet/AspNetCore.Docs/issues/14863
答案 1 :(得分:1)
将Powershell升级到5.1
这是您可以根据系统要求从其下载的链接。