gpt4 book ai didi

entity-framework - 在 ASP.NET 5 和 EF7 (beta 7) 中使用现有数据库

转载 作者:行者123 更新时间:2023-12-04 07:22:48 25 4
gpt4 key购买 nike

我正在尝试使用 ASP.NET 和 EF 7, beta 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" ]
}
}

现在,我已经浏览了谷歌并检查了以下问题:

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

Generating code from an existing database EF7

我已尝试运行以下所有命令,如这些帖子中所述:
dnx ef dbcontext scaffold "ConnectionString" EntityFramework.SqlServer
dnx . ef dbcontext scaffold "<connectionString>"
Scaffold-DbContext '<connectionString>'

每次我收到以下错误:

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



我究竟做错了什么?

从空模板项目访问我的远程数据库应该是一个非常简单的过程,但我已经为此奋斗了一段时间。有人能指出我正确的方向吗?

最佳答案

在聊天中讨论时,我们发现从 C:\Users\<username>\.dnx\runtimes 中删除已安装的运行时并使用 dnvm upgrade 重新安装最新版本是解决方案。

提示:首先检查是否dnvm已更新到最新版本。您可以使用 dnvm update-self 更新它或通过删除 C:\Users\<username>\.dnx\bin 中的内容完全重新安装它文件夹并运行 this PowerShell script .

关于entity-framework - 在 ASP.NET 5 和 EF7 (beta 7) 中使用现有数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32781484/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com