'When executing the command "Scaffold-DbContext" I get the error "ScriptHalted"
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
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?
Solution 1:[1]
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
Solution 2:[2]
Upgrade Powershell to 5.1
This is the link from where you can download according to your system requirement.
Solution 3:[3]
I have had the same error, everything was correct and there was no problem with the packages, nor problems with PowerShell. What happened was that I copied the script that I had done before from GitHub and pasted it into the Visual Studio package management console, without knowing that when I copied this from GitHub I copied a strange character that was invisible in the console, but which was causing the error.
Be careful when copying and pasting code or scripts because this can happen to you.
Solution 4:[4]
You should enable the options allowTain As follow and make sur that the Access-Control-Allow-Origin header is enable for your site
function downloadDiv(divid) {
html2canvas(document.getElementById(divid), {allowTaint : true}).then(function (canvas) {
$("#previewImg").append(canvas);
var anchorTag = document.createElement("a");
document.body.appendChild(anchorTag);
// document.getElementById(divid+"2").appendChild(canvas);
anchorTag.download = "Visitor_"+divid+".png";
anchorTag.href = canvas.toDataURL();
anchorTag.target = '_blank';
anchorTag.click();
});
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | DoÄŸa Babacan |
| Solution 2 | rkpaul |
| Solution 3 | kuudev |
| Solution 4 | BETOMBO |

