如何使用Mac上的Visual Studio代碼將數據庫發佈到Azure?

asp.net-core azure azure-sql-database entity-framework-core visual-studio-code

我在Mac上使用Visual Studio Code構建了asp.net MVC Core Web應用程序。該應用程序一直在localhost中使用數據庫(EF)。

我有一個Azure帳戶,創建了Web App + SQL數據庫。然後我將appsetting.json的連接字符串更改為Azure SQL數據庫提供的連接字符串。

使用git push azure master命令將該網站部署到Azure Web App。但是如何將數據庫發佈到Azure?


appsetting.json

"ConnectionStrings": {
"AzureConnection": "Server=tcp:myapp-test.database.windows.net,1433;Initial Catalog=myapp-test;Persist Security Info=False;User ID=***;Password=***;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
}

運行dotnet ef database update後的輸出:

bash-3.2$ dotnet ef database update
Project MyApp (.NETCoreApp,Version=v1.0) will be compiled because project is not safe for incremental compilation. Use --build-profile flag for more information.
Compiling BlueJacket for .NETCoreApp,Version=v1.0
Bundling with configuration from /Users/matt/Documents/MyApp/bundleconfig.json
Processing wwwroot/css/site.min.css
Processing wwwroot/js/site.min.js
Compilation succeeded.
0 Warning(s)
0 Error(s)
Time elapsed 00:00:05.1136780
(The compilation time can be improved. Run "dotnet build --build-profile" for more information)
Done.

熱門答案

您是否在Azure中創建了數據庫?你有連接字符串嗎?

打開Package-Manager並運行“Update-Database”



Related

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