1

I'm using Entity Framework with a code first model; I've got my InitialCreate migration setup and working locally, I can run code against my database context, and everything works.

But when I deploy my project to Azure, I just get a connection string error ("Format of the initialization string does not conform to specification starting at index 0.").

I can't seem to find where in the Publish dialog are the options to create the Azure database. -- Do I have to create the database separately and hook them up manually? -- If so, what exact process should I follow. Does the database need to have contents?

I thought Microsoft was making a big deal that this could all be done in a single deploy step, but that doesn't seem to be the case from my current experience.

1 Answer 1

1

When you publish your project in the publish dialog, there is an option for the code first migration in the Settings tab, it will automatically show your data context and it will give you the option to set the remote connection string, and this will add a section in web.config to specify the data context and the Migration class to run during the migration process. It will also allow you to set if you want to run the code first Migration or not.

enter image description here

You can also take a backup from the dev and clear the data then upload it to Azure SQL DB, this way the code first data context will check at first connection and it will find the code an database the same

Sign up to request clarification or add additional context in comments.

2 Comments

I had that box already checked. -- It seems the problem is that you have to actually create an empty database in Azure, and specify a connection string. -- I had assumed that the code first stuff could just create the database in Azure.
I don't believe it will able able to create the database in Azure because you have to specify the region, resource group, server, passwords and many other details that Code First will not be able to handle by itself,. you have to create the database by yourself and use its connection string here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.