【发布时间】:2023-03-28 07:33:01
【问题描述】:
我有一个运行和使用 Azure SQL 数据库的 Microsoft Azure 网站,其唯一目的是存储和检索用户帐户。但是,我还需要一个移动客户端,因此根据大量在线教程(例如THIS),我必须将数据库表的“模式”从“dbo”更改为我的移动服务名称“usermobileservice”。
这是使用 SQL 查询完成的:
CREATE SCHEMA usermobileservice;
ALTER SCHEMA usermobileserviceTRANSFER dbo.usertable;
这成功了,我可以使用我的移动应用程序连接到数据库,但现在我无法使用我的 Azure 网站访问数据库!给我这个错误:
Server Error in '/' Application.
Invalid object name 'UserTable'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'UserTable'.
我相信 ASP.NET Web 应用程序无法再找到数据库表,因为我更改了架构?在网站和移动服务之间共享数据的正确方法是什么?
【问题讨论】:
-
那是因为您更改了架构。您需要更新 Web 应用程序查询以使用
usermobileservice.UserTable,或创建一个将usermobileservice作为默认架构的 SQL 帐户,并更新连接字符串以使用此用户。 -
天哪!这解释了很多。由于制作全新的 SQL 很麻烦,先生,我该如何更新 Web 应用程序查询? @BrendanGreen
标签: asp.net azure azure-sql-database azure-mobile-services azure-web-roles