asp.net - Azure 上的 Web 应用程序和数据库主机

标签 asp.net asp.net-mvc azure azure-sql-database azure-web-app-service

大家好, 我是 Asp.net 和 Azure 的新手。我在本文档 link 的帮助下从事 ASP.NET 工作。 ,当我通过在 Azure 上使用最新门户创建 Web 应用程序在 Azure 上发布我的项目时,但它只是我在 Azure 上的应用程序主机。现在我需要将我的项目数据库发布到 Azure。在当前门户中,当我们在 Azure 上创建 Web 应用程序来托管数据库以及 Web 项目时,数据库选项不存在。但在旧门户中,当我们在 Azure 上发布 Web 项目时,随着文档链接的引导,数据库选项也会出现在那里。
谁能解释一下,即使我的项目已部署在 Azure 上,如何将我的 Web App 现有数据库部署到 Azure 上?

最佳答案

How can I deploy my existing Web App Database to Azure on the new portal.

如果您使用 Entity Framework 的代码优先模型,则在发布 Web 应用程序时只需配置 Web 应用程序的连接字符串。 Entity Framework 将自动为您生成表。

如果数据库中存在要迁移到 Azure SQL 数据库的现有数据。您可以下载一个名为Migration Assistant的工具这将帮助你做到这一点。详细步骤请引用以下链接。

SQL Server database migration to SQL Database in the cloud

In the documentation he is using the old dashboard of Azure in which database option is attached with the Web App Publish procedure.

旧仪表板和新仪表板之间的一个小区别是,创建应用服务时创建 Azure SQL 数据库功能是隐藏的。您需要单击“资源管理器其他 Azure 服务”链接来打开用于创建 Azure SQL 数据库的新窗口。

enter image description here

enter image description here

创建数据库后,您可以在发布 Web 应用程序时在“设置”选项卡中选择数据库。

您还可以直接在 Azure 门户中创建数据库。创建数据库后,您可以从概览页面获取连接字符串。

If you make changes to a database schema and are using code first EF, will EF update your database schema when you redeploy your web app?

这取决于您是否已启用并运行迁移。在发布设置窗口中,我们可以单击[执行代码优先迁移]按钮来更新数据库架构。

enter image description here

如果在设置窗口中禁用此按钮,我们需要在 Package Manager Console 中运行 Enable-Migrations 命令。

在 Visual Studio 中点击菜单 Tool -> NuGet Package Manager -> Package Manager Console,输入 Enable-Migrations 并运行。

关于asp.net - Azure 上的 Web 应用程序和数据库主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42493857/

相关文章:

c# - 如何使 HtmlGenericControl 属性 runat = "server"。从代码中访问它?

c# - 有没有办法让 RazorEngine 抛出异常来呈现使用 JSON 作为数据模型的模板?

node.js - Azure "Web apps"服务 : auto-install npm modules from package. json

python - 在 Blob 存储中创建文件夹层次结构时生成意外链接

azure - github操作不使用azure中的正确spn来执行terraform

c# - ASP.NET/WCF : Why are logical/physical threads dropping on full GC cycle?

c# - 为什么这个方法对不同的用户吐出相同的结果

ASP.NET:文字的文本属性内的单引号和双引号

javascript - 检测与 JQuery 数据表的交互

asp.net-mvc - LabelFor 显示属性名称而不是 Display 属性