Using existing database with ASP.NET 5 and EF7 (beta 7) dnx entity-framework entity-framework-core


I'm trying to connect to my existing database using an empty template project for ASP.NET and EF 7, beta 7. This is what my project.json looks like:

  "webroot": "wwwroot",
  "userSecretsId": "aspnet5-Titanes2015-409e9e37-b7bb-4185-b7aa-6dc336087524",
  "version": "1.0.0-*",

  "dependencies": {
    "EntityFramework.Commands": "7.0.0-beta7",
    "EntityFramework.SqlServer": "7.0.0-beta7",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.Facebook": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.Google": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.MicrosoftAccount": "1.0.0-beta7",
    "Microsoft.AspNet.Authentication.Twitter": "1.0.0-beta7",
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta7",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta7",
    "Microsoft.AspNet.Mvc": "6.0.0-beta7",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta7",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta7",
    "Microsoft.Framework.Configuration.Abstractions": "1.0.0-beta7",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
    "Microsoft.Framework.Configuration.UserSecrets": "1.0.0-beta7",
    "Microsoft.Framework.Logging": "1.0.0-beta7",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta7",
    "Microsoft.Framework.Logging.Debug" : "1.0.0-beta7",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7"

  "commands": {
    "web": "Microsoft.AspNet.Hosting --config hosting.ini",
    "ef": "EntityFramework.Commands"

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

  "exclude": [

  "publishExclude": [

  "Data": {
    "DefaultConnection": {
      "ConnectionString": "Server=192.168.XX.XXX\\devsql;Database=XXXXXXX;Trusted_Connection=True;user id=XXXXXX;password=XXXXXX;MultipleActiveResultSets=true"

  "EntityFramework": {
    "ApplicationDbContext": {
      "ConnectionStringKey": "Data:DefaultConnection:ConnectionString"

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

Now, I have looked all over Google and already checked the following questions:

Database-first EF7-beta7 dnx ef dbcontext scaffold command fails

Generating code from an existing database EF7

I have tried running all of the following commands, as mentioned in those posts:

dnx ef dbcontext scaffold "ConnectionString" EntityFramework.SqlServer
dnx . ef dbcontext scaffold "<connectionString>"
Scaffold-DbContext '<connectionString>'

Every single time I get the following error:

The term 'dnx' 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

What am I doing wrong?

Accessing my remote database from an empty template project should be a pretty straightforward process, but I've been fighting this for a while. Could anyone point me in the right direction?

5/23/2017 11:51:37 AM

Accepted Answer

While discussing in the chat, we figured out that removing the installed runtimes from C:\Users\<username>\.dnx\runtimes and re-installing the latest version with dnvm upgrade was the solution.

Tip: first check if dnvm is updated to the latest version. You can update it with dnvm update-self or completely re-install it by removing the content in the C:\Users\<username>\.dnx\bin folder and running this PowerShell script.

9/25/2015 12:50:44 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow