当执行命令"Scaffold-DbContext"时,我收到错误"ScriptHalted" [英] When executing the command "Scaffold-DbContext" I get the error "ScriptHalted"

查看:121
本文介绍了当执行命令"Scaffold-DbContext"时,我收到错误"ScriptHalted"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试计算 entity framework 教程"

数据库图片

使用者:
-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服务器=.\ SQLEXPRESS1;数据库= SCHOOLDB.MDF; Trusted_Connection = True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir模型

-我收到一个错误:名称"Scaffold-DbContext"未被识别为cmdlet,函数,脚本文件或可执行程序的名称.检查正确性.名称的拼写以及路径的存在和正确性,然后重试.行:1个字符:19+ Scaffold-DbContext<<<<服务器=.\ SQLEXPRESS1;数据库= SCHOOLDB.MDF; Trusted_Connection = True;"Microsoft.EntityFrameworkCore.SqlServer -OutputDir模型+ CategoryInfo:ObjectNotFound:(Scaffold-DbContext:字符串)[],CommandNotFoundException+ FullyQualifiedErrorId:CommandNotFoundException

-我安装了 Microsoft.EntityFrameworkCore.Tools (根据建议-" Scaffold-DbContext'不被识别->需要EF工具//github.com )`

-我运行命令: PM>Scaffold-DbContext服务器=.\ SQLEXPRESS1;数据库= SCHOOLDB.MDF; Trusted_Connection = True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir模型
-我收到错误消息: ScriptHalted
问题.
如何解决"ScriptHalted"错误?

解决方案

我今天遇到了同样的问题,并且我使用的是Windows7.Windows7使用的是powershell 2.0,因此我将其升级到5.1,您可以从此处进行升级- https://docs.microsoft.com/zh-CN/powershell/scripting/install/installing-windows-powershell?view = powershell-6

升级此解决了我的问题.我从这里找到了此解决方案- https://github.com/aspnet/AspNetCore.Docs/issues/14863

I am trying to compute the entity framework tutorial" Creating a Model for an Existing Database in Entity Framework Core // entityframeworktutorial.net"-  

When I enter the command: PM> Scaffold-DbContext" Server =. \ SQLEXPRESS1; Database = SCHOOLDB.MDF; Trusted_Connection = True; " Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models  
I get the error: ScriptHalted  

Database Picture

Used by:
   - Visual Studio - 2019. Community - 16.3.6;
   - Console application. Core 3.0;
   - Microsoft.EntityFrameworkCore - 3.0.0;
   - Microsoft.EntityFrameworkCore.Tools - 3.0.0;
  Story:
  - I installed "Microsoft.EntityFrameworkCore - 3.0.0;"
  - I run the command: PM> Scaffold-DbContext" Server =. \ SQLEXPRESS1; Database = SCHOOLDB.MDF; Trusted_Connection = True; " Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

  - I get an error: 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

  - I installed Microsoft.EntityFrameworkCore.Tools (according to the recommendation -"Scaffold-DbContext 'is not recognized -> require EF Tools // github.com")`

  - I run the command: PM> Scaffold-DbContext" Server =. \ SQLEXPRESS1; Database = SCHOOLDB.MDF; Trusted_Connection = True; " Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
  - I get an error: ScriptHalted
  Question.
How to fix the "ScriptHalted" error?

解决方案

I had the same problem today and I am using Windows 7. Windows 7 uses powershell 2.0 so I upgraded it to 5.1, you can upgrade it from here - https://docs.microsoft.com/en-us/powershell/scripting/install/installing-windows-powershell?view=powershell-6

Upgrading this solved my problem. I found this solution from here - https://github.com/aspnet/AspNetCore.Docs/issues/14863

这篇关于当执行命令"Scaffold-DbContext"时,我收到错误"ScriptHalted"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆