public static bool Export(string sourceDbConString, string outDacFilePath) { bool result = false; var sourceConBuilder = new SqlConnectionStringBuilder(sourceDbConString); var services = new DacServices(sourceConBuilder.ConnectionString); services.ProgressChanged += ((s, e) => { Console.WriteLine("Ëxporting Dacpack Status:{0} , Message:{1}.", e.Status, e.Message); }); string blobName; if (System.IO.File.Exists(outDacFilePath)) { System.IO.File.Delete(outDacFilePath); } using (FileStream stream = File.Open(outDacFilePath, FileMode.Create, FileAccess.ReadWrite)) { Console.WriteLine("starting bacpac export"); DacExportOptions opts = new DacExportOptions() { TargetEngineVersion = EngineVersion.Default, Storage = DacSchemaModelStorageType.Memory, VerifyFullTextDocumentTypesSupported = false }; services.Extract(packageStream: stream, databaseName: sourceConBuilder.InitialCatalog, applicationName: "Schema_Exporter", applicationVersion: Version.Parse("1.0.0.0")); //services.ExportBacpac(stream, sourceConBuilder.InitialCatalog, options:opts,tables:null); stream.Flush(); return(true); } return(result); }
public bool TryExportBacpac(string filePath, out string error, IEnumerable<Tuple<string, string>> tables = null, DacExportOptions exportOptions = null) { error = null; try { ExportBacpac(filePath, tables, exportOptions); return true; } catch (Exception ex) { error = ex.Message; return false; } }
public void ExportBacpac(string filePath, IEnumerable<Tuple<string, string>> tables = null, DacExportOptions extractOptions = null) { DacServices ds = new DacServices(this.BuildConnectionString()); ds.ExportBacpac(filePath, this.DatabaseName, extractOptions, tables); }
public bool TryExportBacpac(string filePath, out string error, IEnumerable <Tuple <string, string> > tables = null, DacExportOptions exportOptions = null) { error = null; try { ExportBacpac(filePath, tables, exportOptions); return(true); } catch (Exception ex) { error = ex.Message; return(false); } }
public void ExportBacpac(string filePath, IEnumerable <Tuple <string, string> > tables = null, DacExportOptions extractOptions = null) { DacServices ds = new DacServices(this.BuildConnectionString()); ds.ExportBacpac(filePath, this.DatabaseName, extractOptions, tables); }