/// <summary>
        /// Uninstall a schema group from the database.
        /// </summary>
        /// <remarks>This is a transactional operation</remarks>
        /// <param name="schemaGroup">The group to uninstall</param>
        /// <exception cref="ArgumentNullException">If schemaGroup is null</exception>
        /// <exception cref="SqlException">If any object fails to uninstall</exception>
        public void Uninstall (string schemaGroup)
        {
            // validate the arguments
            if (schemaGroup == null) throw new ArgumentNullException ("schemaGroup");

            // the schema changes must be done in a transaction
            try
            {
                using (TransactionScope transaction = new TransactionScope ())
                {
                    // open the connection
                    OpenConnection ();

                    // make sure we have a schema registry
                    SchemaRegistry registry = new SchemaRegistry (_connection);

                    // sort the objects in drop order (reverse create order)
                    List<string> names = registry.GetObjectNames (schemaGroup);
                    names.Sort (delegate (string n1, string n2)
                    {
                        return -registry.GetObjectType (n1).CompareTo (registry.GetObjectType (n2));
                    });

                    // delete any objects that are in the specified schema group
                    foreach (string objectName in names)
                    {
                        if (DroppingObject != null)
                            DroppingObject (this, new SchemaEventArgs (SchemaEventType.BeforeDrop, objectName));

                        SchemaObjectType type = registry.GetObjectType (objectName);
                        if (type == SchemaObjectType.Table)
							DropTableDepencencies(objectName, null, TableScriptOptions.IncludeTableModifiers, true);
                        SchemaObject.Drop (this, _connection, type, objectName);
                        registry.DeleteObject (objectName);
                    }

                    // commit the changes
                    registry.Update ();
                    transaction.Complete();
                }
            }
            finally
            {
                _connection.Dispose ();
            }
        }
        private void DropObjects (SchemaRegistry registry, List<string> dropObjects, List<SchemaObject> addObjects)
        {
            // drop objects
            foreach (string objectName in dropObjects)
            {
                if (DroppingObject != null)
                    DroppingObject (this, new SchemaEventArgs (SchemaEventType.BeforeDrop, objectName));

                // drop any table dependencies, if any
                SchemaObjectType type = registry.GetObjectType (objectName);
                switch (type)
                {
					case SchemaObjectType.UserDefinedType:
						DropTypeDependencies(objectName, addObjects);
						break;

					case SchemaObjectType.View:
						DropViewDependencies (objectName, addObjects);
						break;

                    case SchemaObjectType.Table:
						DropTableDepencencies(objectName, null, TableScriptOptions.IncludeTableModifiers | TableScriptOptions.AllXmlIndexes, true);
                        break;

                    case SchemaObjectType.PrimaryKey:
						DropTableDepencencies(SchemaObject.TableNameFromIndexName(objectName), addObjects, TableScriptOptions.AddAtEnd | TableScriptOptions.AllXmlIndexes, false);
                        break;

                    case SchemaObjectType.PrimaryXmlIndex:
						DropTableDepencencies(SchemaObject.TableNameFromIndexName(objectName), addObjects, TableScriptOptions.AddAtEnd | TableScriptOptions.SecondaryXmlIndexes, false);
                        break;
                }

                SchemaObject.Drop (this, _connection, type, objectName);
                registry.DeleteObject (objectName);
				ResetScripter ();
            }
        }