- $actual_definition = $this->entityManager->getDefinition($entity_type->id());
- // @todo Instead of switching the wrapped entity type, we should be able to
- // instantiate a new table mapping for each entity type definition. See
- // https://www.drupal.org/node/2274017.
- $this->storage->setEntityType($entity_type);
-
- // Delete entity tables.
- foreach ($this->getEntitySchemaTables() as $table_name) {
+
+ $field_storage_definitions = $this->entityManager->getLastInstalledFieldStorageDefinitions($entity_type->id());
+ $table_mapping = $this->storage->getCustomTableMapping($entity_type, $field_storage_definitions);
+
+ // Delete entity and field tables.
+ foreach ($table_mapping->getTableNames() as $table_name) {