/// <summary>
        /// Publishes the DacPac to the shard provided in the constructor.
        /// </summary>
        /// <param name="dacPacPath">The dac pac path.</param>
        /// <param name="dacProfilePath">The dac profile path.</param>
        /// <returns><c>true</c> if a new database was created, <c>false</c> otherwise.</returns>
        public bool PublishDacPac(string dacPacPath, string dacProfilePath)
        {
            // read the DacPac package and profile from files
            var dacPackage = DacPackage.Load(dacPacPath);
            var dacProfile = DacProfile.Load(dacProfilePath);

            return(PublishDacPac(dacPackage, dacProfile));
        }
        /// <summary>
        /// Publishes the DacPac to the shard provided in the constructor.
        /// </summary>
        /// <param name="dacPacStream">The dac pac stream.</param>
        /// <param name="dacProfileStream">The dac profile stream.</param>
        /// <returns><c>true</c> if a new database was created, <c>false</c> otherwise.</returns>
        public bool PublishDacPac(Stream dacPacStream, Stream dacProfileStream)
        {
            // read the DacPac package and profile from files
            var dacPackage = DacPackage.Load(dacPacStream);
            var dacProfile = DacProfile.Load(dacProfileStream);

            return(PublishDacPac(dacPackage, dacProfile));
        }
Exemplo n.º 3
0
        private PackageOptions _unusedOptions = new PackageOptions();   //without this the Microsoft.SqlServer.Dac.Extensions.dll is not included in the build

        public Proxy(string dacPacPath, string profilePath)
        {
            Profile  = DacProfile.Load(profilePath);
            Services = new DacServices(Profile.TargetConnectionString);

            Services.Message         += (sender, args) => Message.Invoke(sender, $"{args.Message.Prefix}, {args.Message.MessageType}, {args.Message.Number}, {args.Message.Message}");
            Services.ProgressChanged += (sender, args) => Message.Invoke(sender, $"{args.Message}, {args.Status.ToString().Replace("Completed", "Complete")}");

            DacpacPath = dacPacPath;
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            var    Options          = new Options();
            string vDacDictionary   = null;
            string vDacProfile      = null;
            string vtargetDatabase  = null;
            string connectionString = null;
            bool   isValid          = false;

            try
            {
                isValid = CommandLine.Parser.Default.ParseArguments(args, Options);
            }
            catch (Exception e)
            {
                Console.WriteLine("there is an error in command line arguments , try reading it from configuration " + e.Message);
            }



            if (isValid)
            {
                vDacDictionary   = Options.DacDictionary;
                vDacProfile      = Options.DacProfile;
                vtargetDatabase  = Options.TargetDatabase;
                connectionString = ConnectionStringResolver(Options, connectionString);
            }
            else
            {
                vDacDictionary   = ConfigurationManager.AppSettings.Get("dac directory");
                vDacProfile      = ConfigurationManager.AppSettings.Get("dac profile");
                vtargetDatabase  = ConfigurationManager.AppSettings.Get("targetdatabase");
                connectionString = ConfigurationManager.ConnectionStrings["Mask"].ConnectionString;
            }
            string path = Directory.GetCurrentDirectory();

            // connectionString = ConnectionStringResolver(Options, connectionString);

            try
            {
                var dp         = DacPackage.Load(path + $@"\" + vDacDictionary);
                var dacService = new DacServices(connectionString);
                var dacProfile = DacProfile.Load(path + $@"\" + vDacProfile);
                dacService.Message += (object sender, Microsoft.SqlServer.Dac.DacMessageEventArgs eventArgs) => Console.WriteLine(eventArgs.Message.Message);

                dacService.Deploy(dp, vtargetDatabase, true, dacProfile.DeployOptions);

                Console.WriteLine("Deployment completed successfully !!!!");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in the deployment. please correct the input " + ex.Message);
            }
            Console.ReadLine();
        }
Exemplo n.º 5
0
 private void LoadDacProfile()
 {
     if (File.Exists(_options.ProfilePath))
     {
         _log.Info("Using Dac profile: " + _options.ProfilePath);
         _dacProfile = DacProfile.Load(_options.ProfilePath);
     }
     else
     {
         _log.Info("Dac profile not used.");
     }
 }
Exemplo n.º 6
0
        private async Task <CreateDeployFilesResult> CreateDeployFilesInternalAsync(string previousVersionDacpacPath,
                                                                                    string newVersionDacpacPath,
                                                                                    string publishProfilePath,
                                                                                    bool createDeployScript,
                                                                                    bool createDeployReport)
        {
            return
                (await Task.Run(() =>
            {
                PublishResult result;
                PublishProfile publishProfile;
                string preDeploymentScriptContent;
                string postDeploymentScriptContent;
                try
                {
                    // Get publish profile
                    var deployOptions = DacProfile.Load(publishProfilePath).DeployOptions;
                    publishProfile = ConvertPublishProfile(deployOptions);

                    // Read the DACPACs
                    using (var previousDacpac = DacPackage.Load(previousVersionDacpacPath, DacSchemaModelStorageType.Memory))
                        using (var newDacpac = DacPackage.Load(newVersionDacpacPath, DacSchemaModelStorageType.Memory))
                        {
                            // Read pre-deployment and post-deployment from new DACPAC.
                            preDeploymentScriptContent = TryToReadDeploymentScriptContent(newDacpac.PreDeploymentScript);
                            postDeploymentScriptContent = TryToReadDeploymentScriptContent(newDacpac.PostDeploymentScript);

                            // Process the input
                            result = DacServices.Script(newDacpac,
                                                        previousDacpac,
                                                        "PRODUCTION",
                                                        new PublishOptions
                            {
                                GenerateDeploymentScript = createDeployScript,
                                GenerateDeploymentReport = createDeployReport,
                                DeployOptions = deployOptions
                            });
                        }
                }
                catch (DacServicesException e)
                {
                    return new CreateDeployFilesResult(GetErrorList(e));
                }

                return new CreateDeployFilesResult(result?.DatabaseScript,
                                                   _xmlFormatService.FormatDeployReport(result?.DeploymentReport),
                                                   preDeploymentScriptContent,
                                                   postDeploymentScriptContent,
                                                   publishProfile);
            }));
        }
Exemplo n.º 7
0
        private void ReadPublishProfile(string targetPublishProfileFile)
        {
            var dacProfile = DacProfile.Load(targetPublishProfileFile);

            DatabaseName = dacProfile.TargetDatabaseName;

            if (IsNullOrWhiteSpace(DatabaseName))
            {
                throw new ArgumentException($"Database Name not found in publish profile \"{targetPublishProfileFile}\". The node \"//Project/PropertyGroup/TargetDatabaseName\" is empty or missed.");
            }

            sqlCmdVariables.Add("DatabaseName", DatabaseName);


            ConnectionString = dacProfile.TargetConnectionString;

            var builder = new SqlConnectionStringBuilder(ConnectionString);

            ServerName = builder.DataSource;
            if (IsNullOrWhiteSpace(ServerName))
            {
                throw new ArgumentException($"No Server name (DataSource) provided in TargetConnectionString property of publish profile {targetPublishProfileFile}. The node \"//Project/PropertyGroup/TargetConnectionString\" is empty or missed.");
            }

            IntegratedSecurity = builder.IntegratedSecurity;

            if (!IntegratedSecurity)
            {
                UserID = builder.UserID;
                if (IsNullOrWhiteSpace(ServerName))
                {
                    throw new ArgumentException($"No UserID provided although the Integrated Security property of TargetConnectionString in publish profile \"{targetPublishProfileFile}\" set to \"false\"");
                }

                Password = builder.Password;
                if (IsNullOrWhiteSpace(ServerName))
                {
                    throw new ArgumentException($"No Password provided although the Integrated Security property of TargetConnectionString in publish profile \"{targetPublishProfileFile}\" set to \"false\"");
                }
            }

            DacDeployOptions = dacProfile.DeployOptions;
        }
Exemplo n.º 8
0
        public void publishChanges()
        {
            string dacpacPath      = @"C:\Program Files (x86)\Jenkins\workspace\FirstDeploymentProject\SQLTestProject\SQLTestProject\bin\Debug\SQLTestProject.dacpac";
            string dacProfilePath  = @"C:\Program Files (x86)\Jenkins\workspace\FirstDeploymentProject\SQLTestProject\SQLTestProject\Dev.publish.xml";
            var    dp              = DacPackage.Load(dacpacPath);
            var    dbDeployOptions = new DacDeployOptions();

            dbDeployOptions.BlockOnPossibleDataLoss = false;
            //dbDeployOptions.SqlCommandVariableValues.
            //Load DacProfile from sql project
            DacProfile d = new DacProfile();

            d = DacProfile.Load(dacProfilePath);
            //var p = new PublishOptions();
            //p.GenerateDeploymentScript = true;
            //p.DatabaseScriptPath = "";
            var dbServices = new DacServices(d.TargetConnectionString);

            dbServices.Deploy(dp, d.TargetDatabaseName, true, dbDeployOptions);
        }
        /// <summary>
        /// Publishes the DacPac to the shard provided in the constructor.
        /// </summary>
        /// <param name="dacPackage">The dac package.</param>
        /// <param name="dacProfile">The dac profile.</param>
        /// <returns><c>true</c> if a new database was created, <c>false</c> otherwise.</returns>
        public bool PublishDacPac(DacPackage dacPackage, DacProfile dacProfile)
        {
            try
            {
                // instantiate a DacPac service
                var dacServices = new DacServices(_shardCatalogConnection.ConnectionString);
                dacServices.Message         += ReceiveDacServiceMessage;
                dacServices.ProgressChanged += ReceiveDacServiceProgressEvent;

                // extract the options from the profile
                var dacDeployOptions = dacProfile.DeployOptions;

                // determine if a new database will be created
                var isNewDb =
                    dacDeployOptions.CreateNewDatabase ||
                    !ShardedDatabaseExists();

                // create the Dac Pac package by loading the DacPac package
                using (var package = dacPackage)
                {
                    // Deploy the Dac Pac package by loading the DacPac package
                    const bool upgradeExistingDb = true;
                    dacServices.Deploy(package, _shardCatalogConnection.Catalog, upgradeExistingDb,
                                       dacDeployOptions);
                }

                //execute post deployment actions to support scale out sharding
                PostPublishDacPacActions(isNewDb);

                return(isNewDb);
            }
            catch (Exception e)
            {
                // todo: Add Logging
                //Logger.WriteToLogText("Failed PublishDacpac: {0} {1} {2}", ex.Source, ex.Message, ex.StackTrace);
                throw;
            }
        }
        /// <summary>
        /// Deploys the database.
        /// </summary>
        /// <param name="connection"></param>
        /// <param name="databaseName"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task DeployAsync(SqlConnection connection, string databaseName, DacProfile profile, CancellationToken cancellationToken)
        {
            if (File.Exists(source) == false)
            {
                throw new FileNotFoundException($"Missing DACPAC '{source}'. Ensure project has been built successfully.", source);
            }

            // will use to identify instance
            var instanceName = await connection.GetServerInstanceName(cancellationToken);

            // check that existing database does not already exist with tag
            if (await IsOutOfDate(connection, databaseName, cancellationToken) == false)
            {
                logger.LogInformation("Database {Name} is up to date.", databaseName);
                return;
            }

            try
            {
                // lock database for deployment
                connection.ChangeDatabase("master");
                if (await connection.GetAppLock($"DATABASE::{databaseName}", timeout: (int)TimeSpan.FromMinutes(5).TotalMilliseconds) < 0)
                {
                    throw new SqlDeploymentException($"Unable to acquire database lock on '{databaseName}'.");
                }

                // load up the DAC services
                using var dac = LoadDacPackage(source);
                var svc = new DacServices(connection.ConnectionString);
                svc.Message         += (s, a) => LogDacServiceMessage(instanceName, databaseName, a);
                svc.ProgressChanged += (s, a) => LogDacServiceProgress(instanceName, databaseName, a);
                var prf = profile ?? new DacProfile();
                var opt = prf.DeployOptions;

                // will specifically drop these
                opt.DoNotAlterReplicatedObjects = false;

                // check if database exists
                if (await connection.ExecuteScalarAsync((string)$"SELECT db_id('{databaseName}')") is short dbid)
                {
                    connection.ChangeDatabase(databaseName);

                    // some items are replicated
                    var helpDbReplicationOption = await connection.ExecuteSpHelpReplicationDbOptionAsync(databaseName, cancellationToken);

                    if (helpDbReplicationOption.TransactionalPublish ||
                        helpDbReplicationOption.MergePublish)
                    {
                        if ((int)await connection.ExecuteScalarAsync("SELECT COUNT(*) FROM sysarticles", null, cancellationToken) > 0)
                        {
                            var reportTxt = svc.GenerateDeployReport(dac, databaseName, opt, cancellationToken);
                            var reportXml = XDocument.Parse(reportTxt);

                            foreach (var operation in reportXml.Root.Elements(dacRptNs + "Operations").Elements(dacRptNs + "Operation"))
                            {
                                if ((string)operation.Attribute("Name") == "TableRebuild" ||
                                    (string)operation.Attribute("Name") == "Drop" ||
                                    (string)operation.Attribute("Name") == "Alter" ||
                                    (string)operation.Attribute("Name") == "Rename")
                                {
                                    foreach (var item in operation.Elements(dacRptNs + "Item"))
                                    {
                                        if ((string)item.Attribute("Type") == "SqlTable" ||
                                            (string)item.Attribute("Type") == "SqlSimpleColumn")
                                        {
                                            await DropReplicatedTableAsync(connection, (string)item.Attribute("Value"), cancellationToken);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // deploy database
                connection.ChangeDatabase("master");
                logger.LogInformation("Publishing {DacPacFile} to {Database} at {InstanceName}.", source, databaseName, instanceName);
                svc.Deploy(dac, databaseName, true, opt, cancellationToken);

                // generate files for file groups
                connection.ChangeDatabase(databaseName);
                foreach (var group in await GetFileGroupsWithMissingFiles(connection, cancellationToken))
                {
                    await CreateDefaultFilesForFileGroup(connection, databaseName, group, cancellationToken);
                }

                // record that the version we just deployed
                await SetDacTag(connection, databaseName, GetDacTag(source), cancellationToken);
            }
            catch (SqlException e)
            {
                logger.LogError(e, "Exception deploying DACPAC to {Name} at {InstanceName}.", databaseName, instanceName);
                throw;
            }
            finally
            {
                try
                {
                    // we might have been closed as part of the error
                    if (connection.State == ConnectionState.Open)
                    {
                        connection.ChangeDatabase("master");
                        await connection.ReleaseAppLock($"DATABASE::{databaseName}");
                    }
                }
                catch (SqlException e)
                {
                    logger.LogError(e, "Unable to release database lock on {Name}.", databaseName);
                    throw;
                }
            }
        }
 /// <summary>
 /// Initializes a new instance.
 /// </summary>
 /// <param name="instanceName"></param>
 /// <param name="name"></param>
 /// <param name="source"></param>
 /// <param name="profile"></param>
 public SqlDeploymentDatabasePackageAction(string instanceName, string name, string source, DacProfile profile) :
     base(instanceName)
 {
     Name    = name ?? throw new ArgumentNullException(nameof(name));
     Source  = source ?? throw new ArgumentNullException(nameof(source));
     Profile = profile ?? throw new ArgumentNullException(nameof(profile));
 }
        /// <summary>
        /// Loads the profile.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        DacProfile LoadProfile(SqlDeploymentCompileContext context)
        {
            var profile = new DacProfile();

            // load external profile source
            if (ProfileSource != null)
            {
                // ensure path is rooted
                var source = ProfileSource.Value.Expand(context);
                if (Path.IsPathRooted(source) == false)
                {
                    source = Path.Combine(context.RelativeRoot, source);
                }

                profile = DacProfile.Load(source);
            }

            if (DeployOptions.AdditionalDeploymentContributorArguments != null)
            {
                profile.DeployOptions.AdditionalDeploymentContributorArguments = DeployOptions.AdditionalDeploymentContributorArguments.Value.Expand <string>(context);
            }
            if (DeployOptions.AdditionalDeploymentContributorPaths != null)
            {
                profile.DeployOptions.AdditionalDeploymentContributorPaths = DeployOptions.AdditionalDeploymentContributorPaths.Value.Expand <string>(context);
            }
            if (DeployOptions.AdditionalDeploymentContributors != null)
            {
                profile.DeployOptions.AdditionalDeploymentContributors = DeployOptions.AdditionalDeploymentContributors.Value.Expand <string>(context);
            }
            if (DeployOptions.AllowDropBlockingAssemblies != null)
            {
                profile.DeployOptions.AllowDropBlockingAssemblies = DeployOptions.AllowDropBlockingAssemblies.Value.Expand <bool>(context);
            }
            if (DeployOptions.AllowIncompatiblePlatform != null)
            {
                profile.DeployOptions.AllowIncompatiblePlatform = DeployOptions.AllowIncompatiblePlatform.Value.Expand <bool>(context);
            }
            if (DeployOptions.AllowUnsafeRowLevelSecurityDataMovement != null)
            {
                profile.DeployOptions.AllowUnsafeRowLevelSecurityDataMovement = DeployOptions.AllowUnsafeRowLevelSecurityDataMovement.Value.Expand <bool>(context);
            }
            if (DeployOptions.BackupDatabaseBeforeChanges != null)
            {
                profile.DeployOptions.BackupDatabaseBeforeChanges = DeployOptions.BackupDatabaseBeforeChanges.Value.Expand <bool>(context);
            }
            if (DeployOptions.BlockOnPossibleDataLoss != null)
            {
                profile.DeployOptions.BlockOnPossibleDataLoss = DeployOptions.BlockOnPossibleDataLoss.Value.Expand <bool>(context);
            }
            if (DeployOptions.BlockWhenDriftDetected != null)
            {
                profile.DeployOptions.BlockWhenDriftDetected = DeployOptions.BlockWhenDriftDetected.Value.Expand <bool>(context);
            }
            if (DeployOptions.CommandTimeout != null)
            {
                profile.DeployOptions.CommandTimeout = DeployOptions.CommandTimeout.Value.Expand <int>(context);
            }
            if (DeployOptions.CommentOutSetVarDeclarations != null)
            {
                profile.DeployOptions.CommentOutSetVarDeclarations = DeployOptions.CommentOutSetVarDeclarations.Value.Expand <bool>(context);
            }
            if (DeployOptions.CompareUsingTargetCollation != null)
            {
                profile.DeployOptions.CompareUsingTargetCollation = DeployOptions.CompareUsingTargetCollation.Value.Expand <bool>(context);
            }
            if (DeployOptions.CreateNewDatabase != null)
            {
                profile.DeployOptions.CreateNewDatabase = DeployOptions.CreateNewDatabase.Value.Expand <bool>(context);
            }
            if (DeployOptions.DatabaseLockTimeout != null)
            {
                profile.DeployOptions.DatabaseLockTimeout = DeployOptions.DatabaseLockTimeout.Value.Expand <int>(context);
            }
            //if (DeployOptions.DatabaseSpecification != null)
            //    profile.DeployOptions.DatabaseSpecification = DeployOptions.DatabaseSpecification.Value.Expand<bool>(context);
            if (DeployOptions.DeployDatabaseInSingleUserMode != null)
            {
                profile.DeployOptions.DeployDatabaseInSingleUserMode = DeployOptions.DeployDatabaseInSingleUserMode.Value.Expand <bool>(context);
            }
            if (DeployOptions.DisableAndReenableDdlTriggers != null)
            {
                profile.DeployOptions.DisableAndReenableDdlTriggers = DeployOptions.DisableAndReenableDdlTriggers.Value.Expand <bool>(context);
            }
            if (DeployOptions.DoNotAlterChangeDataCaptureObjects != null)
            {
                profile.DeployOptions.DoNotAlterChangeDataCaptureObjects = DeployOptions.DoNotAlterChangeDataCaptureObjects.Value.Expand <bool>(context);
            }
            if (DeployOptions.DoNotAlterReplicatedObjects != null)
            {
                profile.DeployOptions.DoNotAlterReplicatedObjects = DeployOptions.DoNotAlterReplicatedObjects.Value.Expand <bool>(context);
            }
            if (DeployOptions.DoNotDropObjectTypes != null)
            {
                profile.DeployOptions.DoNotDropObjectTypes = DeployOptions.DoNotDropObjectTypes?.SelectMany(i => i.Expand <string>(context)?.Split(';').Select(i => ToObjectType(i))).ToArray();
            }
            if (DeployOptions.DropConstraintsNotInSource != null)
            {
                profile.DeployOptions.DropConstraintsNotInSource = DeployOptions.DropConstraintsNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropDmlTriggersNotInSource != null)
            {
                profile.DeployOptions.DropDmlTriggersNotInSource = DeployOptions.DropDmlTriggersNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropExtendedPropertiesNotInSource != null)
            {
                profile.DeployOptions.DropExtendedPropertiesNotInSource = DeployOptions.DropExtendedPropertiesNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropIndexesNotInSource != null)
            {
                profile.DeployOptions.DropIndexesNotInSource = DeployOptions.DropIndexesNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropObjectsNotInSource != null)
            {
                profile.DeployOptions.DropObjectsNotInSource = DeployOptions.DropObjectsNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropPermissionsNotInSource != null)
            {
                profile.DeployOptions.DropPermissionsNotInSource = DeployOptions.DropPermissionsNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropRoleMembersNotInSource != null)
            {
                profile.DeployOptions.DropRoleMembersNotInSource = DeployOptions.DropRoleMembersNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.DropStatisticsNotInSource != null)
            {
                profile.DeployOptions.DropStatisticsNotInSource = DeployOptions.DropStatisticsNotInSource.Value.Expand <bool>(context);
            }
            if (DeployOptions.ExcludeObjectTypes != null)
            {
                profile.DeployOptions.ExcludeObjectTypes = DeployOptions.ExcludeObjectTypes?.SelectMany(i => i.Expand <string>(context)?.Split(';').Select(i => ToObjectType(i))).ToArray();
            }
            if (DeployOptions.GenerateSmartDefaults != null)
            {
                profile.DeployOptions.GenerateSmartDefaults = DeployOptions.GenerateSmartDefaults.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreAnsiNulls != null)
            {
                profile.DeployOptions.IgnoreAnsiNulls = DeployOptions.IgnoreAnsiNulls.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreAuthorizer != null)
            {
                profile.DeployOptions.IgnoreAuthorizer = DeployOptions.IgnoreAuthorizer.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreColumnCollation != null)
            {
                profile.DeployOptions.IgnoreColumnCollation = DeployOptions.IgnoreColumnCollation.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreColumnOrder != null)
            {
                profile.DeployOptions.IgnoreColumnOrder = DeployOptions.IgnoreColumnOrder.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreComments != null)
            {
                profile.DeployOptions.IgnoreComments = DeployOptions.IgnoreComments.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreCryptographicProviderFilePath != null)
            {
                profile.DeployOptions.IgnoreCryptographicProviderFilePath = DeployOptions.IgnoreCryptographicProviderFilePath.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreDdlTriggerOrder != null)
            {
                profile.DeployOptions.IgnoreDdlTriggerOrder = DeployOptions.IgnoreDdlTriggerOrder.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreDdlTriggerState != null)
            {
                profile.DeployOptions.IgnoreDdlTriggerState = DeployOptions.IgnoreDdlTriggerState.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreDefaultSchema != null)
            {
                profile.DeployOptions.IgnoreDefaultSchema = DeployOptions.IgnoreDefaultSchema.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreDmlTriggerOrder != null)
            {
                profile.DeployOptions.IgnoreDmlTriggerOrder = DeployOptions.IgnoreDmlTriggerOrder.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreDmlTriggerState != null)
            {
                profile.DeployOptions.IgnoreDmlTriggerState = DeployOptions.IgnoreDmlTriggerState.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreExtendedProperties != null)
            {
                profile.DeployOptions.IgnoreExtendedProperties = DeployOptions.IgnoreExtendedProperties.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreFileAndLogFilePath != null)
            {
                profile.DeployOptions.IgnoreFileAndLogFilePath = DeployOptions.IgnoreFileAndLogFilePath.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreFilegroupPlacement != null)
            {
                profile.DeployOptions.IgnoreFilegroupPlacement = DeployOptions.IgnoreFilegroupPlacement.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreFileSize != null)
            {
                profile.DeployOptions.IgnoreFileSize = DeployOptions.IgnoreFileSize.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreFillFactor != null)
            {
                profile.DeployOptions.IgnoreFillFactor = DeployOptions.IgnoreFillFactor.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreFullTextCatalogFilePath != null)
            {
                profile.DeployOptions.IgnoreFullTextCatalogFilePath = DeployOptions.IgnoreFullTextCatalogFilePath.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreIdentitySeed != null)
            {
                profile.DeployOptions.IgnoreIdentitySeed = DeployOptions.IgnoreIdentitySeed.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreIncrement != null)
            {
                profile.DeployOptions.IgnoreIncrement = DeployOptions.IgnoreIncrement.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreIndexOptions != null)
            {
                profile.DeployOptions.IgnoreIndexOptions = DeployOptions.IgnoreIndexOptions.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreIndexPadding != null)
            {
                profile.DeployOptions.IgnoreIndexPadding = DeployOptions.IgnoreIndexPadding.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreKeywordCasing != null)
            {
                profile.DeployOptions.IgnoreKeywordCasing = DeployOptions.IgnoreKeywordCasing.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreLockHintsOnIndexes != null)
            {
                profile.DeployOptions.IgnoreLockHintsOnIndexes = DeployOptions.IgnoreLockHintsOnIndexes.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreLoginSids != null)
            {
                profile.DeployOptions.IgnoreLoginSids = DeployOptions.IgnoreLoginSids.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreNotForReplication != null)
            {
                profile.DeployOptions.IgnoreNotForReplication = DeployOptions.IgnoreNotForReplication.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreObjectPlacementOnPartitionScheme != null)
            {
                profile.DeployOptions.IgnoreObjectPlacementOnPartitionScheme = DeployOptions.IgnoreObjectPlacementOnPartitionScheme.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnorePartitionSchemes != null)
            {
                profile.DeployOptions.IgnorePartitionSchemes = DeployOptions.IgnorePartitionSchemes.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnorePermissions != null)
            {
                profile.DeployOptions.IgnorePermissions = DeployOptions.IgnorePermissions.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreQuotedIdentifiers != null)
            {
                profile.DeployOptions.IgnoreQuotedIdentifiers = DeployOptions.IgnoreQuotedIdentifiers.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreRoleMembership != null)
            {
                profile.DeployOptions.IgnoreRoleMembership = DeployOptions.IgnoreRoleMembership.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreRouteLifetime != null)
            {
                profile.DeployOptions.IgnoreRouteLifetime = DeployOptions.IgnoreRouteLifetime.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreSemicolonBetweenStatements != null)
            {
                profile.DeployOptions.IgnoreSemicolonBetweenStatements = DeployOptions.IgnoreSemicolonBetweenStatements.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreTableOptions != null)
            {
                profile.DeployOptions.IgnoreTableOptions = DeployOptions.IgnoreTableOptions.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreUserSettingsObjects != null)
            {
                profile.DeployOptions.IgnoreUserSettingsObjects = DeployOptions.IgnoreUserSettingsObjects.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreWhitespace != null)
            {
                profile.DeployOptions.IgnoreWhitespace = DeployOptions.IgnoreWhitespace.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreWithNocheckOnCheckConstraints != null)
            {
                profile.DeployOptions.IgnoreWithNocheckOnCheckConstraints = DeployOptions.IgnoreWithNocheckOnCheckConstraints.Value.Expand <bool>(context);
            }
            if (DeployOptions.IgnoreWithNocheckOnForeignKeys != null)
            {
                profile.DeployOptions.IgnoreWithNocheckOnForeignKeys = DeployOptions.IgnoreWithNocheckOnForeignKeys.Value.Expand <bool>(context);
            }
            if (DeployOptions.IncludeCompositeObjects != null)
            {
                profile.DeployOptions.IncludeCompositeObjects = DeployOptions.IncludeCompositeObjects.Value.Expand <bool>(context);
            }
            if (DeployOptions.IncludeTransactionalScripts != null)
            {
                profile.DeployOptions.IncludeTransactionalScripts = DeployOptions.IncludeTransactionalScripts.Value.Expand <bool>(context);
            }
            if (DeployOptions.LongRunningCommandTimeout != null)
            {
                profile.DeployOptions.LongRunningCommandTimeout = DeployOptions.LongRunningCommandTimeout.Value.Expand <int>(context);
            }
            if (DeployOptions.NoAlterStatementsToChangeClrTypes != null)
            {
                profile.DeployOptions.NoAlterStatementsToChangeClrTypes = DeployOptions.NoAlterStatementsToChangeClrTypes.Value.Expand <bool>(context);
            }
            if (DeployOptions.PopulateFilesOnFileGroups != null)
            {
                profile.DeployOptions.PopulateFilesOnFileGroups = DeployOptions.PopulateFilesOnFileGroups.Value.Expand <bool>(context);
            }
            if (DeployOptions.RegisterDataTierApplication != null)
            {
                profile.DeployOptions.RegisterDataTierApplication = DeployOptions.RegisterDataTierApplication.Value.Expand <bool>(context);
            }
            if (DeployOptions.RunDeploymentPlanExecutors != null)
            {
                profile.DeployOptions.RunDeploymentPlanExecutors = DeployOptions.RunDeploymentPlanExecutors.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptDatabaseCollation != null)
            {
                profile.DeployOptions.ScriptDatabaseCollation = DeployOptions.ScriptDatabaseCollation.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptDatabaseCompatibility != null)
            {
                profile.DeployOptions.ScriptDatabaseCompatibility = DeployOptions.ScriptDatabaseCompatibility.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptDatabaseOptions != null)
            {
                profile.DeployOptions.ScriptDatabaseOptions = DeployOptions.ScriptDatabaseOptions.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptDeployStateChecks != null)
            {
                profile.DeployOptions.ScriptDeployStateChecks = DeployOptions.ScriptDeployStateChecks.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptFileSize != null)
            {
                profile.DeployOptions.ScriptFileSize = DeployOptions.ScriptFileSize.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptNewConstraintValidation != null)
            {
                profile.DeployOptions.ScriptNewConstraintValidation = DeployOptions.ScriptNewConstraintValidation.Value.Expand <bool>(context);
            }
            if (DeployOptions.ScriptRefreshModule != null)
            {
                profile.DeployOptions.ScriptRefreshModule = DeployOptions.ScriptRefreshModule.Value.Expand <bool>(context);
            }
            foreach (var kvp in DeployOptions.SqlCommandVariableValues)
            {
                profile.DeployOptions.SqlCommandVariableValues[kvp.Key] = kvp.Value.Expand <string>(context);
            }
            if (DeployOptions.TreatVerificationErrorsAsWarnings != null)
            {
                profile.DeployOptions.TreatVerificationErrorsAsWarnings = DeployOptions.TreatVerificationErrorsAsWarnings.Value.Expand <bool>(context);
            }
            if (DeployOptions.UnmodifiableObjectWarnings != null)
            {
                profile.DeployOptions.UnmodifiableObjectWarnings = DeployOptions.UnmodifiableObjectWarnings.Value.Expand <bool>(context);
            }
            if (DeployOptions.VerifyCollationCompatibility != null)
            {
                profile.DeployOptions.VerifyCollationCompatibility = DeployOptions.VerifyCollationCompatibility.Value.Expand <bool>(context);
            }
            if (DeployOptions.VerifyDeployment != null)
            {
                profile.DeployOptions.VerifyDeployment = DeployOptions.VerifyDeployment.Value.Expand <bool>(context);
            }

            return(profile);
        }