Problem: Changing the model in a code first Mobile Services project and then publishing to Azure causes the following error:
System.Data.SqlClient.SqlException (0x80131904): Cannot open database "master" requested by the login. The login failed. Login failed for user 'xxxxxxxxxxxxxxxxxx'.
Steps to reproduce:
- Visual Studio Community 2015 New Project -> Web Application -> Mobile Service
- Publish straight to Azure (create new Mobile Service - select cheapest tier for the db)
- Send GET in Fiddler to http://whatever.azure-mobile.net/Tables/todoitem
- Receive 200 OK with 2 items that were seeded into the db by the default project
- Make a small change to the model (e.g. add the following to the ToDoItem class) public string Changed { get; set; }
- Publish the changes to Azure
- Send GET in Fiddler to http://whatever.azure-mobile.net/Tables/todoitem
- This time a 500 Internal Server Error is received and the error I quoted at the start appears twice in the Mobile Service Logs in Azure
I have checked and the database still exists without the change to the model, so I assume Azure wasn't able to drop it for some reason.
In the default Mobile Service project, in the WebApiConfig class the database initializer is set to be of a type that inherits DropCreateDatabaseIfModelChanges. So shouldn't Azure drop the database and recreate it? I had this problem in a customised project of mine, so tried this test with the default mobile service and was able to reproduce it, shouldn't this default site work outside of the box, at least?
Is there anything I need to do to allow Azure to drop the database? The error message suggests it can't log in, but we've proven that it can by the fact that the Seed method in the MobileServiceInitializer class was definitely called when the service was first published (because we were able to return 2 ToDoItems with the first GET request sent from fiddler).
Any ideas? Any help would be much appreciated, thanks.