How can we deploy a SQL Server Data project as we did with a Database Project?
-
Saturday, March 31, 2012 7:31 PM
We currently write our own database deployment methods in C# using the exposed API's:
SchemaDeploymentConstructorSchemaDeploymentDeploymentPlanWhat direction can you provide to do the same thing with the SQL Server Data project?
All Replies
-
Monday, April 02, 2012 10:00 PMModerator
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
- Edited by Gert Drapers (MSFT)Microsoft Employee, Editor Monday, April 02, 2012 10:01 PM
- Marked As Answer by Janet YeildingMicrosoft Employee, Owner Tuesday, April 03, 2012 4:23 PM
-
Tuesday, April 03, 2012 4:14 AMThank you very much. How do we set SQL Command Variables that are necessary, such as when we reference the Master database?
-
Friday, August 17, 2012 7:30 PM
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.

