Ejemplo n.º 1
0
        /// <summary>
        /// Updates the model inside an existing dacpac. All other parts of the package (the refactor log, pre/post deployment scripts,
        /// contributors to use etc) stay the same.
        /// </summary>
        /// <param name="dacpacPath"></param>
        public void UpdateDacpacModelWithFilter(string dacpacPath)
        {
            DisposableList disposables = new DisposableList();

            try
            {
                TSqlModel model         = disposables.Add(new TSqlModel(dacpacPath, DacSchemaModelStorageType.Memory));
                TSqlModel filteredModel = disposables.Add(CreateFilteredModel(model));

                // Note that the package must be opened in ReadWrite mode - this will fail if this isn't specified
                DacPackage package = disposables.Add(DacPackage.Load(dacpacPath, DacSchemaModelStorageType.Memory, FileAccess.ReadWrite));
                package.UpdateModel(filteredModel, new PackageMetadata());
            }
            finally
            {
                disposables.Dispose();
            }
        }
Ejemplo n.º 2
0
        private void WriteFinalDacpac(TSqlModel model /*, string preScript, string postScript*/)
        {
            var metadata = new PackageMetadata {
                Name = _dacPackage.Name, Description = _dacPackage.Description, Version = _dacPackage.Version.ToString()
            };

            try
            {
                _dacPackage.UpdateModel(model, metadata);
                //DacPackageExtensions.BuildPackage(_targetPath, model, metadata);
            }
            catch (DacServicesException exception)
            {
                Console.WriteLine("Exception[{0}]: {1}\r\nStackTrace: {2}\r\n",
                                  exception.Source,
                                  exception.Message,
                                  exception.StackTrace
                                  );
            }
            //AddScripts(preScript, postScript, _targetPath);
        }