This is where I start when I create a new ASP.NET Core 1.1 project that saves a lot of time. If you follow steps 1 and 2, they will not work immediately, try restarting Visual Studio and go to step 2.
Step 1
Use the following project.json command. Recover packages.
{ "version": "1.0.0-*", "dependencies": { "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0", "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0", "Microsoft.EntityFrameworkCore": "1.1.0", "Microsoft.EntityFrameworkCore.Design": "1.1.0", "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final", "NETStandard.Library": "1.6.1", "Microsoft.NETCore.App": { "type": "platform", "version": "1.1.0" } }, "frameworks": { "netcoreapp1.1": { "imports": "dnxcore50" } }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final", "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4-final" } }
Step 2
Run the query in the package manager console. The following query connects to TestDb db in TestServer
Scaffold-DbContext "Data Source=TestServer;Initial Catalog=TestDb;Persist Security Info=True;User ID={Username};Password={Password}" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -force -v -t dbo.Table1, dbo.Table2, dbo.Table3
source share