Visual Studio Database Project and SQL Azure

后端 未结 3 1016
别那么骄傲
别那么骄傲 2021-02-13 15:52

I\'m really struggling with the best approach for managing a SQL Azure database which is based on a Visual Studio 2010 Database Project. I figured it would be easy enough to use

相关标签:
3条回答
  • 2021-02-13 16:25

    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());
            }
        }
    
    0 讨论(0)
  • 2021-02-13 16:37

    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.

    0 讨论(0)
  • 2021-02-13 16:40

    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.

    0 讨论(0)
提交回复
热议问题