Truncate tables before uninstalling a module in Drupal 8 I'm developing a module in Drupal 8, and because it handles quite a few relations between entities, I always need to add a bit of test data before being able to test the forms for the actual entity I'm working on after a uninstall/reinstall of the module. During install I can add this data in the module.install->xx_install hook. But during uninstall I get the error     

"The following reasons prevent the modules from being uninstalled: There is content for the entity type..."


I tried implementing the uninstall hook and truncate the table there, but it seems the check for existing content is done before this hook runs. How can I truncate the necessary tables without having to do it manually? Having to do it manually slows down development quite a bit. Alternatively, is there a way to speed up development of the entity forms and relations so that I don't always have to install/uninstall the module to see changes?
That's a known issue right now.

There's no way right now to hook into that automatically. And it came up a few times already here too. See this question for example: Module uninstall dependencies

Beside a form or a drush command to do the cleanup, there really isn't much that you do right now, other than improving core. What I'd like to see is a message on the uninstall confirmation form that tells you that it will delete all records of entity type N and then does so in a batch before actually uninstalling. See the referenced flag issue in the other question and my repeated suggestions to open an issue, but so far, nobody could be bothered with doing that. And I didn't find time myself either.

Update

Drupal 8.2 now offers a link on the uninstall form to delete all entities of the given type.