Visual Studio Database Project and SQL Azure Visual Studio Database Project and SQL Azure azure azure

Visual Studio Database Project and SQL Azure


You can use the SQL Azure Migration Wizard and play with it. Maybe you can get the scripts and edit them as you want. Just an idea.


Check out the properties page of the database project. It should show a dropdown containing the various available providers for the project. If you select the Azure provider you should be able to deploy the project as part of your Azure application.


A simple command line tool that replaces invalid SQL Azure statements is all that is needed:

    private const string STARTPLACEHOLDER = "AZURESCRIPTSTARTPLACEHOLDER";    public static void Do(string fileName)    {        // Read the original file        StringBuilder script = new StringBuilder();        using (StreamReader reader = new StreamReader(fileName))        {            script.Append(reader.ReadToEnd());        }        // Remove everything before the start placeholder        int startPlaceHolder = script.ToString().IndexOf(STARTPLACEHOLDER, 0);        if (startPlaceHolder > 0)        {            script.Remove(0, startPlaceHolder + STARTPLACEHOLDER.Length);        }        // Remove WITH clause        script.Replace("WITH (ALLOW_PAGE_LOCKS = ON, ALLOW_ROW_LOCKS = ON, PAD_INDEX = OFF, IGNORE_DUP_KEY = OFF, STATISTICS_NORECOMPUTE = OFF)", string.Empty);        // Create azure compatible output file        using (StreamWriter writer = new StreamWriter(Path.Combine(Path.GetDirectoryName(fileName), Path.GetFileNameWithoutExtension(fileName) + "_Azure" + Path.GetExtension(fileName))))        {            writer.Write(script.ToString());        }    }