Example #1
0
        internal async static Task DeployAsync(
            this IDockerContainerManager manager,
            ContainerResourceSettings settings,
            Stream source,
            string databaseConnection,
            string databaseName)
        {
            using (var dacPackage = Microsoft.SqlServer.Dac.DacPackage.Load(source))
            {
                var deployService   = new DacServices(databaseConnection);
                var deployScriptRaw = deployService.GenerateDeployScript(dacPackage, databaseName, DacpacOptions.Deploy);
                var deployScript    = new DeployScript(deployScriptRaw);

                deployScript.SetVariable("DefaultDataPath", "/tmp/");
                deployScript.SetVariable("DefaultLogPath", "/tmp/");

                var sqlScript = deployScript.Generate();

                FileInfo scriptFile  = CreateSqlFile(sqlScript);
                var      copyContext = new CopyContext(scriptFile.FullName, $"/tmp/{scriptFile.Name}");

                await manager.CopyToContainer(copyContext);

                await manager.InvokeCommandAsync(SqlCommand.ExecuteFile(copyContext.Destination, settings));

                File.Delete(scriptFile.FullName);
            }
        }
Example #2
0
        public void Run()
        {
            // load dacpacs
            DacPackage pk01 = DacPackage.Load(folderPath01 + file01);
            DacPackage pk02 = DacPackage.Load(folderPath02 + file02);

            // configure (same as .publish xml)
            DacDeployOptions options = new DacDeployOptions
            {
                AdditionalDeploymentContributors = "DBContributorsPack.DropToTxtContributor",

                ExcludeObjectTypes = new ObjectType[]
                {
                    ObjectType.Users,
                    ObjectType.RoleMembership
                },

                DropObjectsNotInSource = true,
                DoNotDropObjectTypes   = new ObjectType[]
                {
                    ObjectType.DatabaseRoles
                }
            };

            // compare
            string s = DacServices.GenerateDeployScript(pk01, pk02, "name", options);

            Console.WriteLine(s);
            Console.ReadLine();
        }
        private string GenerateScriptAndOptionallyDeploy(string dbName, DacDeployOptions options, bool runDeployment, int currentIteration)
        {
            if (options == null)
            {
                options = new DacDeployOptions();
            }

            using (DacPackage dacpac = DacPackage.Load(_dacpacPath, DacSchemaModelStorageType.Memory))
            {
                string connectionString = "Data Source=" + DataSourceName + ";Integrated Security=True";

                DacServices dacServices = new DacServices(connectionString);

                // Script then deploy, to support debugging of the generated plan
                string script   = dacServices.GenerateDeployScript(dacpac, dbName, options);
                string filePath = GetTestFilePath(string.Format(CultureInfo.CurrentCulture, "deployscript{0}.sql", currentIteration));
                File.WriteAllText(filePath, script);
                Console.WriteLine("Deployment script written to {0}", filePath);

                if (runDeployment)
                {
                    dacServices.Deploy(dacpac, dbName, true, options);
                    AssertDeploySucceeded(ServerConnectionString, dbName);
                }

                return(script);
            }
        }
        private static void CreateSqlChangeScript(string srcConString, SqlConnectionStringBuilder TargetCon, DacServices TargetdacServices, DacPackage dacpac)
        {
            var deployScript  = TargetdacServices.GenerateDeployScript(dacpac, TargetCon.InitialCatalog);
            var outScriptPath = GetDacFileName(srcConString) + "_DeployScript.sql";

            System.IO.File.WriteAllText(outScriptPath, deployScript);
            Console.WriteLine("DeployScript.{0}", deployScript);
        }
Example #5
0
        private static string MainExec(string sourceDacFilePath, string sourceConnectionString, string targerConnectionString, string username, string password, DacDeployOptions options = null, CancellationTokenSource C_Token = null)
        {
            using (var impersonator = new ImpersonateIt())
            {
                impersonator.Impersonate(username, password);
                //if (!System.IO.File.Exists(sourceDacFilePath))
                //{
                //    Console.WriteLine("source dac file does not exists, Creating new file. ");
                //    if (string.IsNullOrWhiteSpace(sourceConnectionString))
                //    {
                //        Console.Error.WriteLine("Source Connection string is required for creating a bac file.");
                //        return string.Empty;
                //    }

                //}
                Export(sourceConnectionString, @"C:\Temp\Source_dacFile.dacpac");
                Export(targerConnectionString, @"C:\Temp\Target_dacFile.dacpac");

                var TargetCon         = new SqlConnectionStringBuilder(targerConnectionString);
                var TargetdacServices = new DacServices(TargetCon.ConnectionString);

                TargetdacServices.Message         += ((s, e) => { Console.WriteLine(e?.Message.ToString()); });
                TargetdacServices.ProgressChanged += ((s, e) => { Console.WriteLine("Status:{0}, Message:{1}", e?.Status, e?.Message.ToString()); });

                if (options == null)
                {
                    options = new DacDeployOptions();
                }

                using (DacPackage dacpac = DacPackage.Load(sourceDacFilePath, DacSchemaModelStorageType.Memory))
                {
                    // Script then deploy, to support debugging of the generated plan
                    // string script = dacServices.GenerateDeployScript(dacpac, dbName, options);
                    var deployReport = TargetdacServices.GenerateDeployReport(dacpac, TargetCon.InitialCatalog);

                    var deployScript = TargetdacServices.GenerateDeployScript(dacpac, TargetCon.InitialCatalog);

                    var DiffReport = TargetdacServices.GenerateDriftReport(TargetCon.InitialCatalog);

                    var outReportPath = Path.Combine(@"C:\Temp\", "DeployReport_" + DateTime.Now.ToString("yyyyMMMdd HHmmsstt") + ".sql");
                    System.IO.File.WriteAllText(outReportPath, deployReport);
                    var outScriptPath = Path.Combine(@"C:\Temp\", "DeployScript_" + DateTime.Now.ToString("yyyyMMMdd HHmmsstt") + ".sql");
                    System.IO.File.WriteAllText(outScriptPath, deployScript);
                    var outDiffReport = Path.Combine(@"C:\Temp\", "DeployDiff_" + DateTime.Now.ToString("yyyyMMMdd HHmmsstt") + ".sql");
                    System.IO.File.WriteAllText(outDiffReport, DiffReport);

                    Console.WriteLine("output Report and script generated.");
                    Console.WriteLine("DeployReport.{0}", deployReport);
                    Console.WriteLine("DiffReport.{0}", DiffReport);
                    Console.WriteLine("DeployScript.{0}", deployScript);


                    return("Done.");
                }
            }
            return("");
        }
Example #6
0
        public void TestStopDeployment()
        {
            // Given database name
            string dbName = TestContext.TestName;

            // Delete any existing artifacts from a previous run
            TestUtils.DropDatabase(TestUtils.ServerConnectionString, dbName);

            // When deploying using the deployment stopping contributor
            try
            {
                DacDeployOptions options = new DacDeployOptions
                {
                    AdditionalDeploymentContributors = DeploymentStoppingContributor.ContributorId
                };

                // Deploy initial schema, should pass as no data motion
                using (DacPackage dacpac = DacPackage.Load(_dacpacPath, DacSchemaModelStorageType.Memory))
                {
                    DacServices dacServices = new DacServices(TestUtils.ServerConnectionString);
                    dacServices.Deploy(dacpac, dbName, false, options);
                }

                // Create schema that will cause data motion by adding column before existing one
                using (TSqlModel model = new TSqlModel(SqlServerVersion.Sql110, null))
                {
                    model.AddObjects("CREATE TABLE [dbo].[t1] (motion int NOT NULL, c1 INT NOT NULL PRIMARY KEY)");
                    DacPackageExtensions.BuildPackage(_dacpacPath, model, new PackageMetadata());
                }

                // Attempt to deploy and verify it fails as there's now data motion blocking it
                using (DacPackage dacpac = DacPackage.Load(_dacpacPath, DacSchemaModelStorageType.Memory))
                {
                    DacServices dacServices = new DacServices(TestUtils.ServerConnectionString);

                    try
                    {
                        dacServices.GenerateDeployScript(dacpac, dbName, options);
                        Assert.Fail("Expected Deployment to fail and exception to be thrown");
                    }
                    catch (DacServicesException expectedException)
                    {
                        Assert.IsTrue(expectedException.Message.Contains(DeploymentStoppingContributor.ErrorViaPublishMessage),
                                      "Expected Severity.Error message passed to base.PublishMessage to block deployment");
                        Assert.IsTrue(expectedException.Message.Contains(DeploymentStoppingContributor.ErrorViaThrownException),
                                      "Expected thrown exception to block deployment");
                    }
                }
            }
            finally
            {
                TestUtils.DropDatabase(TestUtils.ServerConnectionString, dbName);
            }
        }
Example #7
0
        static void Main(string[] args)
        {
            ILogger consoleLogger = new ConsoleLogger();

            if (args.Count() == 0 || args.Any(a => a.Contains("help")) || args.Any(a => a.Contains("/h")) || args.Any(a => a.Contains("-h")) || args.Any(a => a.Contains("?h")) || args.Any(a => a.Contains("-?")) || args.Any(a => a.Contains("/?")))
            {
                WriteHelpInfo(consoleLogger);
            }
            else
            {
                consoleLogger.WriteInfoLine("Application started");

                string _sourcePackagePath  = GetSourceFileFromArgs(args);
                string _targetPackagePath  = GetTargetFileFromArgs(args);
                string _scriptpath         = GetScriptFileFromArgs(args);
                string _targetDatabaseName = "MyTargetDb";
                bool   _nosqlcmd           = GetNoSqlCmdFromArgs(args);

                var _deployOptions = new DacDeployOptions();
                _deployOptions.SqlCommandVariableValues.Add("RefDb1", "MyReferencedDb");
                _deployOptions.CommentOutSetVarDeclarations = _nosqlcmd;

                consoleLogger.WriteInfoLine($"Source path set to: {_sourcePackagePath}");
                consoleLogger.WriteInfoLine($"Target path set to: {_targetPackagePath}");
                consoleLogger.WriteInfoLine($"Script path set to: {_scriptpath}");
                consoleLogger.WriteInfoLine($"NoSQLcmd set to: {_nosqlcmd}");

                try
                {
                    using (var sourcePac = DacPackage.Load(_sourcePackagePath))
                    {
                        using (var targetPac = DacPackage.Load(_targetPackagePath))
                        {
                            consoleLogger.WriteInfoLine("Generating deploy script");
                            string script = DacServices.GenerateDeployScript(sourcePac, targetPac, _targetDatabaseName, _deployOptions);
                            File.WriteAllText(_scriptpath, script);
                        }
                    }
                }
                catch (Exception ex)
                {
                    consoleLogger.WriteErrorLine(ex);
                    consoleLogger.WriteErrorLine("Ending application");
                }
            }
        }
Example #8
0
        private void Deploy(string dbName, DacDeployOptions options = null)
        {
            if (options == null)
            {
                options = new DacDeployOptions();
            }

            using (DacPackage dacpac = DacPackage.Load(_dacpacPath, DacSchemaModelStorageType.Memory))
            {
                DacServices dacServices = new DacServices(TestUtils.ServerConnectionString);

                // Script then deploy, to support debugging of the generated plan
                string script = dacServices.GenerateDeployScript(dacpac, dbName, options);
                File.WriteAllText(GetTestFilePath("deployscript.sql"), script);
                dacServices.Deploy(dacpac, dbName, true, options);
            }
        }
Example #9
0
        internal static string ScriptDacPacDeltas(string platinumDacPacFileName, string targetDacPacFileName, string path, bool allowObjectDelete, bool ignoreCompatError)
        {
            try
            {
                log.LogInformation($"Generating scripts: {Path.GetFileName(platinumDacPacFileName)} vs {Path.GetFileName(targetDacPacFileName)}");
                string           tmpFile = Path.Combine(path, Path.GetFileName(targetDacPacFileName) + ".sql");
                DacDeployOptions opts    = new DacDeployOptions();
                opts.IgnoreExtendedProperties  = true;
                opts.BlockOnPossibleDataLoss   = false;
                opts.IgnoreUserSettingsObjects = true;
                if (allowObjectDelete)
                {
                    opts.DropObjectsNotInSource = true;
                }

                if (ignoreCompatError)
                {
                    opts.AllowIncompatiblePlatform = true;
                }


                DacPackage platPackage = DacPackage.Load(platinumDacPacFileName);
                DacPackage targPackage = DacPackage.Load(targetDacPacFileName);
                string     script      = DacServices.GenerateDeployScript(platPackage, targPackage, Path.GetFileNameWithoutExtension(targetDacPacFileName), opts);
                return(script);
            }
            catch (Microsoft.SqlServer.Dac.DacServicesException dexe)
            {
                if (dexe.ToString().Contains("DeploymentCompatibilityException"))
                {
                    log.LogWarning("Encountered a Deployment Compatibility Exception! Generating scripts with \"AllowIncompatiblePlatform=true\" setting. This may result in script runtime errors.");
                    return(ScriptDacPacDeltas(platinumDacPacFileName, targetDacPacFileName, path, allowObjectDelete, true));
                }
                else
                {
                    log.LogError($"Problem creating scripts between {platinumDacPacFileName} and {targetDacPacFileName}: {dexe.ToString()}");
                    return(string.Empty);
                }
            }
            catch (Exception exe)
            {
                log.LogError($"Problem creating scripts between {platinumDacPacFileName} and {targetDacPacFileName}: {exe.ToString()}");
                return(string.Empty);
            }
        }
Example #10
0
        //This is I can manually see how stuff looks so I can fiddle!

        static void Main(string[] args)
        {
            var dacServices = new DacServices("SERVER=.;Integrated Security=SSPI;initial catalog=SqlPackageFilter");

            using (DacPackage dacpac = DacPackage.Load(@"..\..\..\dacpac\bin\Debug\DacPac.dacpac", DacSchemaModelStorageType.Memory))
            {
                var options = new DacDeployOptions {
                    AdditionalDeploymentContributors = "AgileSqlClub.DeploymentFilterContributor", DropObjectsNotInSource = true
                };
                var mesages = new List <string>();
                dacServices.Message += (sender, eventArgs) =>
                {
                    mesages.Add(eventArgs.Message.Message);
                };

                var script = dacServices.GenerateDeployScript(dacpac, "SqlPackageFilter", options);
            }
        }
        public void TestStopDeployment()
        {
            // Given database name
            string dbName = TestContext.TestName;

            // Delete any existing artifacts from a previous run
            TestUtils.DropDatabase(ServerConnectionString, dbName);

            // When deploying using the deployment stopping contributor
            try
            {
                DacDeployOptions options = new DacDeployOptions
                {
                    AdditionalDeploymentContributors = DeploymentStoppingContributor.ContributorId
                };

                using (DacPackage dacpac = DacPackage.Load(_dacpacPath, DacSchemaModelStorageType.Memory))
                {
                    const string connectionString = "Data Source=" + DataSourceName + ";Integrated Security=True";
                    DacServices  dacServices      = new DacServices(connectionString);

                    // Script then deploy, to support debugging of the generated plan
                    try
                    {
                        dacServices.GenerateDeployScript(dacpac, dbName, options);
                        Assert.Fail("Expected Deployment to fail and exception to be thrown");
                    }
                    catch (DacServicesException expectedException)
                    {
                        Assert.IsTrue(expectedException.Message.Contains(DeploymentStoppingContributor.ErrorViaPublishMessage),
                                      "Expected Severity.Error message passed to base.PublishMessage to block deployment");
                        Assert.IsTrue(expectedException.Message.Contains(DeploymentStoppingContributor.ErrorViaThrownException),
                                      "Expected thrown exception to block deployment");
                    }
                }

                // Also expect the deployment to fail
                AssertDeployFailed(ServerConnectionString, dbName);
            }
            finally
            {
                TestUtils.DropDatabase(ServerConnectionString, dbName);
            }
        }
Example #12
0
        internal static void Deploy(
            Stream source,
            string databaseConnection,
            string databaseName,
            IImageSettings settings)
        {
            using (var dacPackage = Microsoft.SqlServer.Dac.DacPackage.Load(source))
            {
                var deployService   = new DacServices(databaseConnection);
                var deployScriptRaw = deployService.GenerateDeployScript(dacPackage, databaseName, DacpacOptions.Deploy);
                var deployScript    = new DeployScript(deployScriptRaw);

                deployScript.SetVariable("DefaultDataPath", "/tmp/");
                deployScript.SetVariable("DefaultLogPath", "/tmp/");

                var sqlScript = deployScript.Generate();
                SqlScript.DeployAndExecute(sqlScript, settings);
            }
        }
Example #13
0
        static void Main(string[] args)
        {
            string folderPath01 = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\TestDBSource\bin\Debug\"));
            string folderPath02 = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\TestDBTarget\bin\Debug\"));

            string file01 = "TestDBSource.dacpac";
            string file02 = "TestDBTarget.dacpac";

            // load dacpacs
            DacPackage pk01 = DacPackage.Load(folderPath01 + file01);
            DacPackage pk02 = DacPackage.Load(folderPath02 + file02);

            // configure (same as .publish xml)
            DacDeployOptions options = new DacDeployOptions
            {
                //AdditionalDeploymentContributors = "TestContributors.MyFirstTestContributor",
                AdditionalDeploymentContributors = "TestContributors.DropToTxtContributor",

                ExcludeObjectTypes = new ObjectType[]
                {
                    ObjectType.Users,
                    ObjectType.RoleMembership
                },

                DropObjectsNotInSource = true,
                DoNotDropObjectTypes   = new ObjectType[]
                {
                    ObjectType.DatabaseRoles
                }
            };

            // compare
            string s = DacServices.GenerateDeployScript(pk01, pk02, "name", options);

            Console.WriteLine(s);
            Console.ReadLine();
        }
        private void Deploy(string dbName, DacDeployOptions options = null)
        {
            if (options == null)
            {
                options = new DacDeployOptions();
            }

            using (DacPackage dacpac = DacPackage.Load(_dacpacPath, DacSchemaModelStorageType.Memory))
            {
                DacServices dacServices = new DacServices(TestUtils.ServerConnectionString);

                // Script then deploy, to support debugging of the generated plan
                string script = dacServices.GenerateDeployScript(dacpac, dbName, options);
                File.WriteAllText(GetTestFilePath("deployscript.sql"), script);
                dacServices.Deploy(dacpac, dbName, true, options);

            }
        }
        public void TestStopDeployment()
        {
            // Given database name
            string dbName = TestContext.TestName;

            // Delete any existing artifacts from a previous run
            TestUtils.DropDatabase(TestUtils.ServerConnectionString, dbName);

            // When deploying using the deployment stopping contributor
            try
            {
                DacDeployOptions options = new DacDeployOptions
                {
                    AdditionalDeploymentContributors = DeploymentStoppingContributor.ContributorId
                };

                using (DacPackage dacpac = DacPackage.Load(_dacpacPath, DacSchemaModelStorageType.Memory))
                {
                    DacServices dacServices = new DacServices(TestUtils.ServerConnectionString);

                    // Script then deploy, to support debugging of the generated plan
                    try
                    {
                        dacServices.GenerateDeployScript(dacpac, dbName, options);
                        Assert.Fail("Expected Deployment to fail and exception to be thrown");
                    }
                    catch (DacServicesException expectedException)
                    {
                        Assert.IsTrue(expectedException.Message.Contains(DeploymentStoppingContributor.ErrorViaPublishMessage),
                            "Expected Severity.Error message passed to base.PublishMessage to block deployment");
                        Assert.IsTrue(expectedException.Message.Contains(DeploymentStoppingContributor.ErrorViaThrownException),
                            "Expected thrown exception to block deployment");
                    }
                }

                // Also expect the deployment to fail
                AssertDeployFailed(TestUtils.ServerConnectionString, dbName);
            }
            finally
            {
                TestUtils.DropDatabase(TestUtils.ServerConnectionString, dbName);
            }
        }
Example #16
0
        public bool GenerateScript(TextWriter writer, bool dropObjectsNotInSource = true)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            VerifyProperties("GenerateScript");

            // Get the database deployment options.
            DacDeployOptions deployOptions = GetDeployOptions();

            deployOptions.DropObjectsNotInSource = dropObjectsNotInSource;

            // Use the package from the SourcePackage property.
            // But if that is null, then create a temporary package.
            // Use try/finally to ensure that the temporary file gets deleted.
            DacPackage tempSourcePackage     = SourcePackage;
            FileInfo   tempSourcePackageFile = null;
            string     deployScript;

            try
            {
                if (tempSourcePackage == null)
                {
                    tempSourcePackageFile = new FileInfo(Path.GetTempFileName());
                    tempSourcePackage     = ExtractSource(tempSourcePackageFile);
                }

                // Generate the deploy script (schema upgrade).
                if (this.TargetPackage == null)
                {
                    // If the target package is not specified, then create a DacServices instance
                    // and use the GenerateDeployScript instance method that takes a target database name.
                    DacServices targetServices = GetTargetDacServices();
                    deployScript = targetServices.GenerateDeployScript(tempSourcePackage, TargetDatabaseName, deployOptions);
                }
                else
                {
                    // Otherwise, since the target package is specified, use the DacServices.GenerateDeployScript
                    // static method that takes a target package.
                    deployScript = DacServices.GenerateDeployScript(tempSourcePackage, TargetPackage, TargetDatabaseName ?? TargetPackage.Name, deployOptions);
                }
            }
            finally
            {
                if (tempSourcePackageFile != null)
                {
                    tempSourcePackageFile.Delete();
                }
            }

            // Try to remove extraneous header, setvar, SQLCMD mode detection, final PRINT statement, etc.
            deployScript = TrimDeployScript(deployScript);

            // If the deploy script is empty after trimming (no schema changes)
            // then return false.
            // Otherwise, write the script and return true.
            if (deployScript.Length == 0)
            {
                return(false);
            }
            else
            {
                SetOptions(writer);
                writer.Write(deployScript);
                return(true);
            }
        }
        private string GenerateScriptAndOptionallyDeploy(string dbName, DacDeployOptions options, bool runDeployment, int currentIteration)
        {
            if (options == null)
            {
                options = new DacDeployOptions();
            }

            using (DacPackage dacpac = DacPackage.Load(_dacpacPath, DacSchemaModelStorageType.Memory))
            {
                DacServices dacServices = new DacServices(TestUtils.ServerConnectionString);

                // Script then deploy, to support debugging of the generated plan
                string script = dacServices.GenerateDeployScript(dacpac, dbName, options);
                string filePath = GetTestFilePath(string.Format(CultureInfo.CurrentCulture, "deployscript{0}.sql", currentIteration));
                File.WriteAllText(filePath, script);
                Console.WriteLine("Deployment script written to {0}", filePath);

                if (runDeployment)
                {
                    dacServices.Deploy(dacpac, dbName, true, options);
                    AssertDeploySucceeded(TestUtils.ServerConnectionString, dbName);
                }

                return script;
            }
        }
Example #18
0
        public static void ApplyDacpac(Stream dacpac, string connectionString, string databaseName, ILogger log)
        {
            var options = new DacDeployOptions()
            {
                BlockOnPossibleDataLoss     = true,
                IncludeTransactionalScripts = true,
                DropDmlTriggersNotInSource  = false,
                DropPermissionsNotInSource  = false,
                DropStatisticsNotInSource   = false,
                DropRoleMembersNotInSource  = false,

                // cambiati rispetto al progetto originale di paonic
                DropConstraintsNotInSource        = true, // vengono inseriti solo in prod ?
                DropExtendedPropertiesNotInSource = true,
                DropIndexesNotInSource            = true, // ci sono indici creati da altri e non presenti nei source?
                DropObjectsNotInSource            = true, // li schema e le viste della BI sono sempre nei source?

                // aggiunti rispetto al progetto originale di paonic
                CreateNewDatabase    = false,
                DoNotDropObjectTypes = new ObjectType[]
                {
                    ObjectType.Aggregates,
                    ObjectType.Assemblies,
                    ObjectType.ApplicationRoles,
                    ObjectType.Audits,
                    ObjectType.BrokerPriorities,
                    ObjectType.Certificates,
                    ObjectType.ClrUserDefinedTypes,
                    ObjectType.Contracts,
                    ObjectType.Credentials,
                    ObjectType.CryptographicProviders,
                    ObjectType.DatabaseRoles,
                    ObjectType.DatabaseAuditSpecifications,
                    ObjectType.Defaults,
                    ObjectType.Endpoints,
                    ObjectType.ErrorMessages,
                    ObjectType.EventNotifications,
                    ObjectType.EventSessions,
                    ObjectType.FullTextCatalogs,
                    ObjectType.FullTextStoplists,
                    ObjectType.LinkedServers,
                    ObjectType.LinkedServerLogins,
                    ObjectType.Logins,
                    ObjectType.MessageTypes,
                    ObjectType.Permissions,
                    ObjectType.RoleMembership,
                    ObjectType.ServerRoleMembership,
                    ObjectType.ServerRoles,
                    ObjectType.Queues,
                    ObjectType.RemoteServiceBindings,
                    ObjectType.Routes,
                    ObjectType.Rules,
                    ObjectType.SearchPropertyLists,
                    ObjectType.Sequences,
                    ObjectType.ServerTriggers,
                    ObjectType.Services,
                    ObjectType.Signatures,
                    ObjectType.Users,
                },
                ExcludeObjectTypes = new ObjectType[]
                {
                    ObjectType.Aggregates,
                    ObjectType.Assemblies,
                    ObjectType.ApplicationRoles,
                    ObjectType.Audits,
                    ObjectType.BrokerPriorities,
                    ObjectType.Certificates,
                    ObjectType.ClrUserDefinedTypes,
                    ObjectType.Contracts,
                    ObjectType.Credentials,
                    ObjectType.CryptographicProviders,
                    ObjectType.DatabaseRoles,
                    ObjectType.DatabaseAuditSpecifications,
                    ObjectType.Defaults,
                    ObjectType.Endpoints,
                    ObjectType.ErrorMessages,
                    ObjectType.EventNotifications,
                    ObjectType.EventSessions,
                    ObjectType.FullTextCatalogs,
                    ObjectType.FullTextStoplists,
                    ObjectType.LinkedServers,
                    ObjectType.LinkedServerLogins,
                    ObjectType.Logins,
                    ObjectType.MessageTypes,
                    ObjectType.Permissions,
                    ObjectType.RoleMembership,
                    ObjectType.ServerRoleMembership,
                    ObjectType.ServerRoles,
                    ObjectType.Queues,
                    ObjectType.RemoteServiceBindings,
                    ObjectType.Routes,
                    ObjectType.Rules,
                    ObjectType.SearchPropertyLists,
                    ObjectType.Sequences,
                    ObjectType.ServerTriggers,
                    ObjectType.Services,
                    ObjectType.Signatures,
                    ObjectType.Users,
                },
                AllowDropBlockingAssemblies        = false,
                AllowIncompatiblePlatform          = true,
                BackupDatabaseBeforeChanges        = false,
                BlockWhenDriftDetected             = false,
                CommentOutSetVarDeclarations       = false,
                CompareUsingTargetCollation        = false,
                DeployDatabaseInSingleUserMode     = false,
                DisableAndReenableDdlTriggers      = false,
                DoNotAlterChangeDataCaptureObjects = true,
                DoNotAlterReplicatedObjects        = true,
                GenerateSmartDefaults = true,
                IgnoreAnsiNulls       = true,
                IgnoreAuthorizer      = true,
                IgnoreColumnCollation = false,
                IgnoreColumnOrder     = true,
                IgnoreComments        = false,
                IgnoreCryptographicProviderFilePath = true,
                IgnoreDdlTriggerOrder                  = true,
                IgnoreDdlTriggerState                  = true,
                IgnoreDefaultSchema                    = true,
                IgnoreDmlTriggerOrder                  = true,
                IgnoreDmlTriggerState                  = true,
                IgnoreExtendedProperties               = false,
                IgnoreFileAndLogFilePath               = true,
                IgnoreFilegroupPlacement               = true,
                IgnoreFileSize                         = true,
                IgnoreFillFactor                       = true,
                IgnoreFullTextCatalogFilePath          = true,
                IgnoreIdentitySeed                     = true,
                IgnoreIncrement                        = true,
                IgnoreIndexOptions                     = false,
                IgnoreIndexPadding                     = false,
                IgnoreKeywordCasing                    = true,
                IgnoreLoginSids                        = true,
                IgnoreLockHintsOnIndexes               = false,
                IgnoreNotForReplication                = true,
                IgnoreObjectPlacementOnPartitionScheme = true,
                IgnorePartitionSchemes                 = false,
                IgnoreQuotedIdentifiers                = true,
                IgnorePermissions                      = true,
                IgnoreRoleMembership                   = true,
                IgnoreRouteLifetime                    = true,
                IgnoreSemicolonBetweenStatements       = true,
                IgnoreTableOptions                     = false,
                IgnoreUserSettingsObjects              = true,
                IgnoreWhitespace                       = true,
                IgnoreWithNocheckOnCheckConstraints    = false,
                IgnoreWithNocheckOnForeignKeys         = false,
                IncludeCompositeObjects                = false,
                NoAlterStatementsToChangeClrTypes      = false,
                PopulateFilesOnFileGroups              = false,
                RegisterDataTierApplication            = false,
                RunDeploymentPlanExecutors             = false,
                ScriptDatabaseCollation                = false,
                ScriptDatabaseCompatibility            = false,
                ScriptDatabaseOptions                  = false,
                ScriptDeployStateChecks                = false,
                ScriptFileSize                         = false,
                ScriptNewConstraintValidation          = true,
                ScriptRefreshModule                    = false,
                UnmodifiableObjectWarnings             = true,
                VerifyCollationCompatibility           = true,
                TreatVerificationErrorsAsWarnings      = false,
                VerifyDeployment                       = true,
            };

            log.Log("Creating connection");
            var service = new DacServices(connectionString);

            service.Message += (x, y) =>
            {
                log.Log(y.Message.Message);
            };
            try
            {
                log.Log("Starting dacpac application");
                using (var package = DacPackage.Load(dacpac))
                {
                    log.Log(service.GenerateDeployScript(package, databaseName, options));
                    service.Deploy(package, databaseName, true, options);
                }
            }
            catch (Exception e)
            {
                log.Log(e.Message, true);
                if (e.InnerException != null)
                {
                    log.Log(e.InnerException.Message, true);
                }
            }
        }