我在Mac上使用Visual Studio Code构建了asp.net MVC Core Web应用程序。该应用程序一直在localhost中使用数据库(EF)。
我有一个创建了Web App + SQL数据库的Azure帐户。然后我将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.
答案 0 :(得分:0)
您是否在Azure中创建了数据库?你有连接字符串吗?
打开Package-Manager并运行“Update-Database”