internal static void FixKeyReferences(IKey keyToCopyInto, IKey keyToCopyFrom)
        {
            // Fix Column references
            foreach (var col in keyToCopyFrom.Columns)
            {
                keyToCopyInto.AddColumn(col.Name);
            }

            // Fix ReferencedKey reference
            if (keyToCopyFrom.ReferencedKey != null)
            {
                ITable referencedTable = keyToCopyInto.Parent.Database.GetTable(keyToCopyFrom.ReferencedKey.Parent.Name, keyToCopyFrom.ReferencedKey.Parent.Schema);

                if (referencedTable != null)
                {
                    keyToCopyInto.ReferencedKey = referencedTable.GetKey(keyToCopyFrom.ReferencedKey.Name);
                }
            }
        }
        protected override void RunOperationInternal()
        {
            var newTable = Object.Clone();

            if (newTable.IsView)
            {
                Database.AddView(newTable);
            }
            else
            {
                Database.AddTable(newTable);
            }

            foreach (IColumn col in Object.Columns)
            {
                newTable.AddColumn(col.Clone());
            }

            foreach (IKey key in Object.Keys)
            {
                IKey newKey = newTable.AddKey(key.Clone());
                newKey.Parent = newTable;

                foreach (var column in key.Columns)
                {
                    newKey.AddColumn(column.Name);
                }
            }

            foreach (IIndex index in Object.Indexes)
            {
                IIndex newIndex = newTable.AddIndex(index.Clone());
                newIndex.Parent = newTable;

                foreach (var column in index.Columns)
                {
                    newIndex.AddColumn(column.Name);
                }
            }
        }