I'm trying to build a webservice/backend for a new mobile app I'm building usuing Xamarin Forms and Azure Services. I've been following this tutorial.
Everything is fine until I get to the section for "Deploy the project to Azure App Service", where I have 2 related issues. I get this same issue with my own DataObjects AND with the standard "ToDoList" application that is given as an example.
- When I go to publish the first time, I select "Update database" on the "Settings" tab in the Publish Wizard in order to push my new DataObjects/Schema through to my new database. Then, I hit publish, and I get an error back saying
System.Data.SqlClient.SqlException (0x80131904): Cannot attach the file '{LocalFilePath}\App_Data\{databaseName}.mdf' as database '{databaseName}'.
I notice that there is NOTHING in the specified "App_Data" folder, is it possible that I need to do something to build the .mdf prior to publishing to the app service? - After this error occurs, and I try to re-publish the database, and the Publish Wizard has 2 differences. First, I no longer have the "Update Database" option, I only have the "Execute Code First Migrations" option on the Settings Tab, and it is grayed out. Second, the Preview tab says "No databases are selected to publish"
I've tried to publish the database through the App Service three different ways, and each of them is giving me the exact same scenario described above, so I think I'm just missing something obvious since I'm new to Azure and Mobile App development.
- Create Mobile App Backend + Service + Database through the Azure Portal, and then deploying the "QuickStart" project from the Azure Portal.
- Following a tutorial similar to the one above, but that was specifically for publishing the ToDoList database schema that is inserted by default. This was the tutorial I followed
- Following the tutorial above but utilizing my own custom DataObjects rather than the ones described in the tutorial.
I've read up on ways to get the "Execute Code First Migrations" to be available, but I haven't found anything that actually allows me to deploy the database yet, as it keeps on saying "No databases are selected to publish", and I can't get the "Update Database" option to show up after that initial failure. Is there anything obvious that I'm missing?