EF7 RC1 The term 'Scaffold-DbContext' is not recognized

entity-framework entity-framework-core


I am trying to use EF7 RC1 to scaffold from an existing database following the instructions at https://media.readthedocs.org/pdf/ef/latest/ef.pdf

When I run the command from the Package Manager Console

Scaffold-DbContext -provider EntityFramework.MicrosoftSqlServer -connection "Server=(localdb)\MSSQLLocalDB;Initial Catalog=Clients_Local;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"

I get this error

Scaffold-DbContext : The term 'Scaffold-DbContext' 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.
At line:1 char:1
+ Scaffold-DbContext -provider EntityFramework.MicrosoftSqlServer -conn ...
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Scaffold-DbContext:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

My project.json looks like this

  "userSecretsId": "aspnet5-WebApplication1-1702fb51-ff21-46b5-8685-eb0834dd86f0",
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true

  "dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer.Design": "7.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }

  "exclude": [
  "publishExclude": [
  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]

After researching this issue I have deleted the contents of C:\Users\.dnx\bin and updated dnvm using


But I still get the same error.

Accepted Answer

It looks like you must use the dnx command, not the Package Manager Console, as described in the RC1 documentation here: http://docs.efproject.net/en/latest/getting-started/aspnet5/existing-db.html

Update: The EF docs have been moving around a bit. The dnx command can now be found here: http://docs.efproject.net/en/latest/platforms/aspnetcore/existing-db.html

In case it moves again, here's the relevant command:

dnx ef dbcontext scaffold "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;" EntityFramework.MicrosoftSqlServer --outputDir Models

Popular Answer

For RC2 the syntax / CLI changed. You can mostly follow the instructions here: https://docs.efproject.net/en/latest/platforms/aspnetcore/existing-db.html, but I had to use these commands instead to generate the scaffolding.

I ran these from the command line, not from the Package Manager Console.

You can use this to check the arguments and options: dotnet ef dbcontext scaffold --help

Example: dotnet ef dbcontext scaffold "Server=(LocalDB)\MSSQLLocalDB;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -c BloggingContext -o BloggingModels


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why