I needed to move an azure project to a new account. My azure project consists of a SQL database and a mobile service connected to that database.
I moved the database by backing up the database into a .bacpac file and importing it in a new Azure account. I recreated the mobile service manually. Because the mobile service needed a different name, I changed the schema on the imported tables by running:
ALTER SCHEMA [NewSchema]
TRANSFER [OldSchema].[TableName]
Now after migration the SELECT
works. In the azure portal I can see all the tables have rows, and the mobile service can read from the database. The problem however is in insert, and in Custom API's of the service.
Those seem to still work with the old schema in mind:
Insert: Error: [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid object name '[OldSchema].[TableName]'. (SqlState: 42S02, Code: 208)
CustomAPI: Error: [Microsoft][SQL Server Native Client 10.0][SQL Server]Invalid object name '[OldSchema].[TableName]'.
There are no references to the old schema that I can find anywhere. Not in the codebase, not in the database.
I even went and executed
SELECT * FROM sys.database_principals
alter user <userName> WITH DEFAULT_SCHEMA = [NewSchema]
for all users.
I am out of ideas. What am I missing, where is it referencing the old schema?
Thank you for your help!
EDIT: I have just tried printing SELECT SCHEMA_NAME()
within the Custom API I am trying to execute. It printed the correct, new, schema name. When I printed SELECT CURRENT_USER
the correct user is printed, with the correct default schema. I am now more confused than ever.