efcore: Reverse-Engineer in RC2: Scaffold-DbContext not working on ASP.NET Core project
Found when updating this tutorial https://docs.efproject.net/en/latest/platforms/aspnetcore/existing-db.html
I’m guessing this is an issue in the way we hand off parameters to the CLI command that we shell out to.
PM> Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer
The term 'localdb' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 47 (26 by maintainers)
Commits related to this issue
- :memo: Scaffold-DbContext workaround for ASP.NET Core Adding docs to workaround https://github.com/aspnet/EntityFramework/issues/5376 for RC2. — committed to dotnet/EntityFramework.Docs by rowanmiller 8 years ago
- Fix #5376 - escape parameters passed to dotnet-ef from PMC — committed to natemcmaster/EntityFrameworkCore by deleted user 8 years ago
I was able to make it work using command window by running the following script on the root folder of my app: dotnet ef dbcontext scaffold “Server=WIN-EHM93AP21CF\SQLEXPRESS;Database=ASPNETCoreDemoDB;Integrated Security=True;” Microsoft.EntityFrameworkCore.SqlServer --output-dir Models/DB
@proudmonkey With commit aaae665 @natemcmaster fixed this so you no longer need the additional single quotes around anything (we automatically do it for you under the covers). As you found - the double quotes are enough.
@rowanmiller I think we need to update the docs at https://docs.efproject.net/en/latest/platforms/aspnetcore/existing-db.html#reverse-engineer-your-model to reflect this.
I managed to do it with opening command prompt at the root of the project with following command (just as same as RC1, changing dnx to dotnet):
dotnet ef dbcontext scaffold "Insert your connection string " Microsoft.EntityFrameworkCore.SqlServer --output-dir Your/Dir --verbose@shrib what version of OS and Visual Studio? If you have Win7 and Powershell 2.0, it’s possible installing the EF cmdlets died silently. cref https://github.com/aspnet/EntityFramework/issues/5292
@DamianReeves weird. We had a similar bug https://github.com/aspnet/EntityFramework/issues/5260. Apparently my fix in #5263 didn’t completely work. As a workaround you can invoke dotnet-ef directly. You’ll need to “cd” to the directory of the project
Not sure if this is related, but I get this message in the PMC after installing RC2: The term ‘Scaffold-DbContext’ is not recognized as the name of a cmdlet, function, script file, or operable program.
Can you add
-Verboseand share the output?