How to remove a deleted term entity from Entity Reference field after deleting the term entity.
For checking which nodes are using the taxonomy term I will use the taxonomy_index table. It makes sense because we know that the table is updating after each updating a node. So in this table, we have relevant data.
For make sure in that you can check these two hooks in taxonomy.module
So let’s get the node ids that are using the term entity and remove the term references from their fields. Please replace dh_extranet on your MODULE_NAME.