What can I do to remove this entity definition from the database? Long story short, in developing a website in Drupal 8 we decided that the custom entity we were building could just as easily be made with standard nodes. We deleted the entity code (or something to that effect) and now, somewhere hidden in the database, is the definition for the team entity that we've removed. Fortunately, this isn't causing too many issues. However, when deleting fields from a content type (and probably in some other circumstances of which I'm not yet aware), we get the following error: 

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "team" entity type does not 
exist. in Drupal\Core\Entity\EntityTypeManager-&gt;getDefinition() (line 133 of 
[...]/core/lib/Drupal/Core/Entity/EntityTypeManager.php).`


I've attempted doing what was suggested here, but it resulted in the above error.

What can I do to clean up the database/website so this error stops happening?
First solution (the best one if you can) (thanks @Clive) :


Put the deleted code back
Uninstall the module
Reinstall the module with the new code


Second solution (ugly, but worked for me)


Open your favorite SQL client (adminer in my case)
Search for your entity id in all tables
Remove all matching entries
Clear the cache