使用ASP.NET 5和EF7的現有數據庫(beta 7)

asp.net-core asp.net-core-mvc dnx entity-framework entity-framework-core

我正在嘗試使用ASP.NET和EF 7的空模板項目連接到我現有的數據庫,這是我的project.json的樣子:

{
  "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": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],

  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ],

  "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" ]
  }
}

現在,我已經瀏覽了整個Google並且已經檢查了以下問題:

數據庫優先EF7-beta7 dnx ef dbcontext scaffold命令失敗

從現有數據庫EF7生成代碼

我已經嘗試運行以下所有命令,如這些帖子中所述:

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

每次我都會收到以下錯誤:

術語“dnx”未被識別為cmdlet函數的名稱,
腳本文件或可操作程序。檢查名稱的拼寫,或者如果包含路徑,請驗證路徑是否正確,然後重試

我究竟做錯了什麼?

從空模板項目訪問我的遠程數據庫應該是一個非常簡單的過程,但我已經打了一段時間。有人能指出我正確的方向嗎?

一般承認的答案

在聊天中討論時,我們發現從C:\Users\<username>\.dnx\runtimes中刪除已安裝的運行C:\Users\<username>\.dnx\runtimes並使用dnvm upgrade重新安裝最新版本是解決方案。

提示:首先檢查dnvm是否已更新到最新版本。您可以使用dnvm update-self更新它,也可以通過刪除C:\Users\<username>\.dnx\bin文件夾中的內容並運行此PowerShell腳本來完全重新安裝它。



Related

許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow