我是一位新的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