I want to scaffold an existing database in Core, and I can use the Package Manager Console (or dotnet) with:

scaffold-dbcontext -connection "Server=.\myserver;Database=mydatabase;
User ID=johnny;Password=johnny;Integrated Security=true;" 
-provider Microsoft.EntityFrameworkCore.SqlServer -context MyNewDbContext

Is there a way to do this through the IDE without the command line? There is a right-click add for everything else, but I cannot find anything to create a new DbContext so that I can scaffold with the VS add scaffolding right-click add menus. I do not mind typing. I wanted to see if it was required to use the Command Line.

Also, is it possible to reference the connection in appsettings.json instead of using the entire connection string (e.g. ".\sqlserver;...")

There is no context generator for .NET Core using the VS2017 IDE that I can find.

2

There are 2 answers

3
ErikEJ On

You can use my free EF Core Power Tools extension!

0
Ilya Chumakov On

I've made that thing myself. Put the command into a .cmd file and then use Open Command Line extension to run it. By default it runs .cmd or .bat files by pressing Shift+Alt+5.

P.S. Unfortunately, I also keep the full connection string in .cmd file. No idea how to read it from appsettings.json except reading by some tricky Powershell command.