使用现有的数据库与ASP.NET 5和EF7(beta 7) [英] Using existing database with ASP.NET 5 and EF7 (beta 7)
问题描述
我正在尝试使用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
},
命令:{
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
],
数据:{
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
}
},
脚本:{
prepublish:[npm install,bower install,gulp clean,gulp min]
}
}
现在,我已经查看过Google,已经检查了以下问题: p>
我尝试运行所有以下命令,如这些帖子所述: 每次我收到以下错误: 术语dnx不被识别为cmdlet的名称,函数, 我做错了什么? 从空模板项目访问我的远程数据库应该是一个非常简单的过程,但我一直在争取一段时间。任何人都可以指向正确的方向? 在聊天中讨论时,我们发现,将已安装的运行时间从 提示:首先检查 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: 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: Every single time I get the following error: The term 'dnx' is not recognized as the name of a cmdlet, function, 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? While discussing in the chat, we figured out that removing the installed runtimes from Tip: first check if 这篇关于使用现有的数据库与ASP.NET 5和EF7(beta 7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
dnx ef dbcontext scaffoldConnectionStringEntityFramework.SqlServer
dnx。 ef dbcontext scaffold< connectionString>
Scaffold-DbContext'< connectionString>'
脚本文件,或可操作的程序。检查名称的拼写,或
如果包含路径,请验证路径是否正确,然后重试
C:\Users\< username> \.dnx\runtimes
,并重新安装最新版本,其中包含 dnvm upgrade
是解决方案。
dnvm
是否更新到最新版本。您可以使用 dnvm update-self
更新它,或者通过删除 C:\Users\< username>中的内容来完全重新安装; \.dnx\bin
文件夹,并运行此PowerShell脚本 。{
"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" ]
}
}
dnx ef dbcontext scaffold "ConnectionString" EntityFramework.SqlServer
dnx . ef dbcontext scaffold "<connectionString>"
Scaffold-DbContext '<connectionString>'
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 againC:\Users\<username>\.dnx\runtimes
and re-installing the latest version with dnvm upgrade
was the solution.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.