我是一位新的Web开发人员,并且正在尝试使用Azure测试服务托管测试站点。尝试使用Azure托管测试站点,但SQL数据库不会传输
我可以看到测试站点(你可以访问此测试):http://kencast20160830102548.azurewebsites.net/
但是,如果你去服务 - > Fazzt - >设备和应用程序的网页,我得到这个错误:
Error. An error occurred while processing your request. Development Mode Swapping to Development environment will display more detailed information about the error that occurred.
Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable toDevelopment, and restarting the application."
这些页面依赖于SQL数据库,所以我认为这是问题所在。
我一直想在这里发表了方向沿着沿:https://docs.asp.net/en/latest/tutorials/publish-to-azure-webapp-using-vs.html
然而,当登录到我的微软Azure账号,我不能找到“配置SQL数据库”弹出框。
该指示似乎不符合Azure中存在的内容。
更新 - 2016年8月31日
我已经研究和学到一点: 我有两个DBContexts一个项目。
当我发布到Azure时,它从ApplicationDBContext发布表,但不从MyCompanyContext发布表。我可以使用SQL Server Object Explorer进行验证。 我可以在Applicationset和MyCompanyDB的appsettings.json文件中看到本地连接字符串。下面是从appsettings.json代码:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-MyCompany-3097a012-5e00-4c25-ad83-2730b4d73b4b;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"Data": {
"MyCompanyContext": {
"ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=MyCompanyContext-f9de2588-77e8-41dd-abb3-84341610b31a;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
}
然而,当我看“的SQL Server对象资源管理器”窗口,我看到托管在Azure上,mycompanydb.database.windows数据库.net(SQL Server 11.0.9231 -mycompanydb,MyCompany_db)只包含“DefaultConnection”数据库中的表,而不包含“MyCompanyContext”中的表。
如何从第二个数据库(MYCompanyContext)将表获取到Azure?
我一直在研究这个Stack Overflow响应,但它在PMC中使用了Enable-Migration。当我这样做时,出现enable-migrations过时的错误。
在本地,我一直做迁移这一点: 附加迁移-c MyCompanyContext
任何帮助,您可以给我将不胜感激。
谢谢!
的配置SQL显示,如果你正在使用EF连接到SQL和向导标识的DbContext类的存在(ATLEAST这就是我的VS 2015)发生。因此,为了让您的应用程序连接到SQL Db,如果您将它存储在appsettings.json文件中,您可能正在读取我称为“Startup.cs”的连接字符串。 https://docs.asp.net/en/latest/tutorials/first-mvc-app/working-with-sql.html。然后发布网络应用程序到azure,如你所发布的链接所示 – Jaya
@JS_GodBlessAll谢谢你的回应,但我不明白。什么是EF?它在评论中包含的链接中提到。我也不明白我应该做什么从这个评论:“所以要让你的应用程序连接到SQL Db,你可能正在读取连接字符串,我称为Startup.cs,如果你有它存储在appsettings。 json file。docs.asp.net/en/latest/tutorials/first-mvc-app/...“这个链接似乎是关于在本地数据库上运行SQL数据库的。我想在Azure上运行它。谢谢! –
np,EF =实体框架;连接到SQL Db是否在Azure或本地 - 您必须适当地配置您的连接字符串。无论它在本地说什么,都将它指向云上的SQL服务器。 Startup.cs是您的.net核心应用程序的入口点。以下是一些有用的链接,帮助您开始https://docs.asp.net/en/latest/data/index.html; http://stackoverflow.com/questions/31097933/setting-the-sql-connection-string-for-asp-net-5-web-app-in-azure – Jaya