How to avoid saving replication triggers to folder?

OJOJ Posts: 3
I'm trying to use the Compare SDK to save my database objects to a disk folder. However I do not want replication triggers included. Have tried with Options.IgnoreReplicationTriggers (see below) but it does not seem have any effect.

Is this possible at all??
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RedGate.SQLCompare.Engine;
using RedGate.SQLCompare.Engine.ReadFromFolder;


namespace SourceGrabber
{
    class Program
    {
        static void Main(string[] args)
        {
            RedGate.SQLCompare.Engine.Database db;

            using (db = new Database())
            {
                db.Register(new ConnectionProperties(@"TheServer", "TheDatabase"), Options.Default | Options.IgnoreReplicationTriggers);
                db.SaveToFolder(@"TheDiskFolder", new WriteToFileOptions());
            }
        }
    }
}

Comments

  • Brian DonahueBrian Donahue Posts: 6,590 Bronze 1
    Hi OJ,

    It looks like you have to compare the database to the script folder and then merge the changes in order to skip the replication trigger. Loading the database and saving it to disk doesn't seem to respect options.
    private const string c_WidgetProductionFolder = @"c:\users\me\My Documents\schema folders\widgetProduction";
    widgetProduction.Register(new ConnectionProperties(".", @"widgetProduction"), Options.Default | Options.IgnoreReplicationTriggers);
                               Database wpScripts = new Database();
                               wpScripts.Register(c_WidgetProductionFolder, null, Options.Default | Options.IgnoreReplicationTriggers);
                               Differences diffs=widgetProduction.CompareWith(wpScripts, Options.Default | Options.IgnoreReplicationTriggers);
                               Work work = new Work();
                               ScriptSynchronizationActions actions = new ScriptSynchronizationActions();
                               work.BuildFromDifferences(diffs, Options.Default | Options.IgnoreReplicationTriggers, true);                    
                               ScriptSynchronizationActions scriptActions = work.ScriptSynchronizationActions;
                                scriptActions.Execute();
    
  • Thanks for your reply Brian. Your work around should work.

    However I concider it a defect, that the Register method does not respect the Options passed in.
Sign In or Register to comment.