When upgrading a Business Central On-Premises environment from BC 22 to BC 25, encountering orphaned tables like Table 5371 (Service Connection Error) and Table 5372 (Service Connection Status) during the Sync-NAVApp step is a common issue. Since these tables existed in BC 22 but were removed in BC 25, the upgrade process may fail because the system does not allow direct removal of tables unless they are temporary or properly migrated.
One of the first steps many try, as you did, is manually deleting these tables from all companies and removing their metadata from the Object Metadata Snapshot table in SQL. While this allows the upgrade to continue, it’s not the safest long-term approach. Direct SQL deletions bypass Business Central’s internal mechanisms, which could lead to reference issues or unexpected behavior if Microsoft modifies the upgrade logic in future versions.
A safer approach is to handle this issue within AL using either an Upgrade Codeunit or a temporary AL extension that retains the tables for a controlled cleanup. If you want to maintain these tables temporarily while ensuring a smooth upgrade, you can create a small AL extension that reintroduces these tables but marks them as ObsoleteState = Removed. This method ensures Business Central recognizes them during the sync process while allowing a controlled deprecation in a later update.
However, a better long-term solution is to use an Upgrade Codeunit to properly check for these tables and remove their data programmatically. This method is much safer than direct SQL deletions, as it ensures Business Central’s upgrade process handles the cleanup properly without leaving behind metadata references that could cause issues. The Upgrade Codeunit should include logic to check if the tables exist and delete their data before allowing the upgrade to proceed.
Another alternative is modifying the schemaUpdateMode in app.json to "Recreate" to clear outdated tables. However, this approach is quite aggressive since it resets the schema for the entire extension and should only be used if you're confident that no dependencies exist on the removed tables.
According to me the best approach is to handle orphaned tables using an Upgrade Codeunit, as it ensures a structured and safe removal process without risking database integrity. If needed, a temporary extension can be used to retain these tables with an obsolete state before removing them in a later update. Avoiding direct SQL modifications is crucial to prevent issues with future Business Central upgrades.
Regards,
Dr. Gomathi S