How do i remove module's data from Orchard database?

asp.net, c#, orchardcms

Solution

A complete uninstall involves deleting the database tables and rows that are associated with your module's name, the names of its features, and of its namespaces. Here is a process that worked for us.

1: Run orchard.exe > package uninstall Orchard.Module.MyModuleName

2: Then, open SQL Server Management Studio and drop the following database table(s) that are associated with your module.

MyModuleName_MyFeatureNameRecord

3: Do a wildcard search of the following table columns. Be sure to search for MyModuleName, MyNamespaceName, MyFeatureName, etc. You will eventually delete all these rows, but not yet.

SELECT *  FROM Orchard_Framework_ContentTypeRecord  WHERE Name LIKE '%%'
SELECT *  FROM Settings_ContentTypeDefinitionRecord  WHERE Name LIKE '%%'
SELECT *  FROM Settings_ContentPartDefinitionRecord  WHERE Name LIKE '%%'
SELECT *  FROM Settings_ShellFeatureRecord  WHERE Name LIKE '%%'
SELECT *  FROM Settings_ShellFeatureStateRecord  WHERE Name LIKE '%%'
SELECT *  FROM Orchard_Framework_DataMigrationRecord  WHERE DataMigrationClass LIKE '%%'

4: From the search results above, make a note of the Id values of rows in these tables.

Orchard_Framework_ContentTypeRecord.Id
Settings_ContentTypeDefinitionRecord.Id 

5: Now that you have recorded Id, delete the rows that you found in step 3 above.

6: Using the Ids collected in step 4, delete the rows from the following tables.

SELECT * FROM Settings_ContentTypePartDefinitionRecord 
    WHERE ContentTypeDefinitionRecord_Id IN()

SELECT * FROM Orchard_Framework_ContentItemRecord 
    WHERE ContentType_id IN ()

That's what worked for me.

Problem

i have installed a module and after the migration and creating tables in `Orchard.sdf` i want to clear all tables and rollback all changes that the migration did. I dropped the tables but i guess some metadata should be removed. how we can clear a modules data completely? thanks.

Original source