Added some more debug info to storeRepository.php on line 74 and 109. (those are creating the error.)
Added $id. To know which store id was causing the issue.
Removing the database tables for stores. (we didn't use anymore with the requested ID).
catalog_category_flat_store_<id>
sequence_creditmemo_<id>
sequence_invoice_<id>
sequence_rma_item_<id>
sequence_order_<id>
sequence_shipment_<id>
And removed items from
cms_page
cms_block with that store id.
After That problem is fixed!