c# - 使用 SQL 数据库在 Azure 门户上部署 ASP.NET MVC 应用程序

标签 c# asp.net-mvc visual-studio azure azure-sql-database

如何在项目中移动本地数据库,以便将该数据库部署到 Azure?当我登录 Azure 时,我收到一个错误:

Error: an error occurred while processing your request

这是因为我没有连接到我的数据库。我已在 Azure 门户上创建了数据库,但它是空的。如何从我的应用程序连接到我的数据库以使其正常工作?

enter image description here

这是完整的错误:

[Win32Exception (0x80004005): The system cannot find the file specified]

[SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)]
....
[EntityException: The underlying provider failed on Open.]

解决方案: 部署应用程序时,单击“发布”->“创建新配置文件”-> 在“探索其他 Azure 服务”字段中单击->“创建 SQL 数据库”

最佳答案

根据您的评论,您的问题变成了将数据库部署到Azure。

有很多方法可以做到这一点。

既然您已经在 Azure 门户上创建了数据库,最简单的方法就是使用 SSMS 部署数据库向导:

enter image description here

更多详细信息,您可以引用此教程:Learn how to Migrate a SQL Server database to SQL Azure server .

数据库成功部署到Azure SQL数据库后,您可以在门户的Azure SQL数据库页面上获取连接字符串:

enter image description here

引用号: Get ADO.NET connection information (optional)

希望这有帮助。

关于c# - 使用 SQL 数据库在 Azure 门户上部署 ASP.NET MVC 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61543074/

相关文章:

c# - Microsoft Visual Studio - 无法在 SSIS 包中打开脚本任务

c# - 剪辑区域不起作用

javascript - 使用 javascript 和 MVC 的回历(阿拉伯语)日历日期选择器

.net - 通过 NuGet 提供命令行工具以在 Visual Studio 中的生成后事件中使用

asp.net-mvc - HtmlHelper 获取路由名称

c# - Entity Framework 代码第一个对象引用多个对象

c# - 显示 "Save as"窗口

c# - 在 C# 中对结构进行装箱/拆箱是否可以产生与原子结构相同的效果?

c# - 从 MVC 应用程序创建 EXE

c# - dapper 和decimal(10,2) 的无效转换