none
How can we deploy a SQL Server Data project as we did with a Database Project?

    Question

  • We currently write our own database deployment methods in C# using the exposed API's:

    SchemaDeploymentConstructor
    
    SchemaDeployment
    
    DeploymentPlan
    

    What direction can you provide to do the same thing with the SQL Server Data project?

    Saturday, March 31, 2012 7:31 PM

Answers

  • By using the DAC v3.0 Framework

    Hosted in %ProgramFiles(x86)%\Microsoft SQL erver\110\DAC\bin\Microsoft.SqlServer.Dac.dll

    It implements all the verbs: Deploy, ExportBacpac, Extract, GenerateCreateScript, GenerateDeployReport, GenerateDeployScript, GeneratedriftReport, ImportBacpac, Register, Unregister, Unpack

    Code looks like this:

    static void Deploy(string conx, string databaseName, string path)
    {
                Console.WriteLine("Performing Deploy of {0} to {1} at {2}", GetServerName(conx), path, System.DateTime.Now.ToLongTimeString());
    
                DacServices dacServices = new DacServices(conx);
    
                dacServices.Message += new EventHandler<DacMessageEventArgs>(receiveDacServiceMessage);
                dacServices.ProgressChanged += new EventHandler<DacProgressEventArgs>(receiveDacServiceProgessMessage);
    
                DacPackage dacpac = DacPackage.Load(path);
    
                dacServices.Deploy(dacpac, databaseName);
    
    }



    @DataDude - www.sqlproj.com


    Monday, April 02, 2012 10:00 PM
    Moderator

All replies

  • By using the DAC v3.0 Framework

    Hosted in %ProgramFiles(x86)%\Microsoft SQL erver\110\DAC\bin\Microsoft.SqlServer.Dac.dll

    It implements all the verbs: Deploy, ExportBacpac, Extract, GenerateCreateScript, GenerateDeployReport, GenerateDeployScript, GeneratedriftReport, ImportBacpac, Register, Unregister, Unpack

    Code looks like this:

    static void Deploy(string conx, string databaseName, string path)
    {
                Console.WriteLine("Performing Deploy of {0} to {1} at {2}", GetServerName(conx), path, System.DateTime.Now.ToLongTimeString());
    
                DacServices dacServices = new DacServices(conx);
    
                dacServices.Message += new EventHandler<DacMessageEventArgs>(receiveDacServiceMessage);
                dacServices.ProgressChanged += new EventHandler<DacProgressEventArgs>(receiveDacServiceProgessMessage);
    
                DacPackage dacpac = DacPackage.Load(path);
    
                dacServices.Deploy(dacpac, databaseName);
    
    }



    @DataDude - www.sqlproj.com


    Monday, April 02, 2012 10:00 PM
    Moderator
  • Thank you very much.  How do we set SQL Command Variables that are necessary, such as when we reference the Master database?
    Tuesday, April 03, 2012 4:14 AM
  • The dacServices.Deploy method given in the sample takes a DacDeployOptions object per the documentation. SQLCMD Variables can be set via a dictionary exposed on the DacDeployOptions.SqlCommandVariableValues.

    Friday, August 17, 2012 7:30 PM