Repository: dbeaver/dbeaver
Issue: SqlServer FK between two schemas doesn't show on UI

<!--
Thank you for reporting an issue.

*IMPORTANT* -  *before* creating a new issue please look around:
 - DBeaver documentation: https://github.com/dbeaver/dbeaver/wiki
 and
 - open issues in Github tracker: https://github.com/dbeaver/dbeaver/issues
  
If you cannot find a similar problem, then create a new issue. Short tips about new issues can be found here: https://github.com/dbeaver/dbeaver/wiki/Posting-issues

Please, do not create issue duplicates. If you find the same or similar issue, just add a comment or vote for this feature. It helps us to track the most popular requests and fix them faster.

Please fill in as much of the template as possible.
-->

#### System information: 
- Operating system: **Windows 10 Version 21H1 Build 19043.1023**
- DBeaver version **21.1.0.202105300349** Community
- Additional extensions 
  DBeaver Git support	1.0.46.202106012023	org.jkiss.dbeaver.git.feature.feature.group	DBeaver Corp
  DevStyle (includes Darkest Dark Theme)	1.11.0.202105260439	com.genuitec.eclipse.theming.core.feature.feature.group	Genuitec, LLC

#### Connection specification:
- Database name and version: **SqlServer Express Microsoft SQL Server 2017 (RTM-GDR) (KB4583456) - 14.0.2037.2 (X64)   Nov  2 2020 19:19:59   Copyright (C) 2017 Microsoft Corporation  Express Edition (64-bit) on Windows 10 Pro 10.0 <X64> (Build 19043: ) (Hypervisor)**
- Driver name **SQL Server**
- Do you use tunnels or proxies (SSH, SOCKS, etc)?  **No**

#### Describe the problem you're observing:
Creating foreign keys between two tables on two different schemas via UI or SQL Script does not show it on Foreign Keys Tab/SubGroup neither on the DDL source tab.

#### Steps to reproduce, if exist:
1. Create a SQL Server database 
2. Create two schemas
3. Create TableOne on schema1
4. Create TableTwo on schema2
5. Create FK from TableTwo to TableOne
6. If you create FK with UI from the Foreign Keys tab when click persist the FK disappear (but is still present on DB)
7. Execute the query `select * from sys.objects` to verify that the object is successfully created


Changed files:
plugins/org.jkiss.dbeaver.ext.mssql/src/org/jkiss/dbeaver/ext/mssql/model/SQLServerSchema.java

diff --git a/plugins/org.jkiss.dbeaver.ext.mssql/src/org/jkiss/dbeaver/ext/mssql/model/SQLServerSchema.java b/plugins/org.jkiss.dbeaver.ext.mssql/src/org/jkiss/dbeaver/ext/mssql/model/SQLServerSchema.java
index dac1924bb9..e41e19e4ef 100644
--- a/plugins/org.jkiss.dbeaver.ext.mssql/src/org/jkiss/dbeaver/ext/mssql/model/SQLServerSchema.java
+++ b/plugins/org.jkiss.dbeaver.ext.mssql/src/org/jkiss/dbeaver/ext/mssql/model/SQLServerSchema.java
@@ -216,10 +216,22 @@ public class SQLServerSchema implements DBSSchema, DBPSaveableObject, DBPQualifi
         return tableCache.getTypedObjects(monitor, this, SQLServerTable.class);
     }
 
+    @Nullable
     public SQLServerTableBase getTable(DBRProgressMonitor monitor, String name) throws DBException {
         return tableCache.getObject(monitor, this, name);
     }
 
+    @Nullable
+    public SQLServerTable getTable(DBRProgressMonitor monitor, long tableId) throws DBException {
+        for (SQLServerTableBase table : tableCache.getAllObjects(monitor, this)) {
+            if (table.getObjectId() == tableId && table instanceof SQLServerTable) {
+                return (SQLServerTable) table;
+            }
+        }
+        log.debug("Table '" + tableId + "' not found in schema " + getName());
+        return null;
+    }
+
     @Association
     public Collection<SQLServerView> getViews(DBRProgressMonitor monitor) throws DBException {
         return tableCache.getTypedObjects(monitor, this, SQLServerView.class);
@@ -659,7 +671,7 @@ public class SQLServerSchema implements DBSSchema, DBPSaveableObject, DBPQualifi
                 return null;
             }
             long refTableId = JDBCUtils.safeGetLong(dbResult, "referenced_object_id");
-            SQLServerTable refTable = getTable(monitor, refTableId);
+            SQLServerTable refTable = refSchema.getTable(monitor, refTableId);
             if (refTable == null) {
                 log.debug("Ref table " + refTableId + " not found in schema " + refSchema.getName());
                 return null;
@@ -684,17 +696,6 @@ public class SQLServerSchema implements DBSSchema, DBPSaveableObject, DBPQualifi
             return new SQLServerTableForeignKey(parent, fkName, null, refConstraint, deleteRule, updateRule, true);
         }
 
-        @Nullable
-        private SQLServerTable getTable(DBRProgressMonitor monitor, long tableId) throws DBException {
-            for (SQLServerTableBase table: tableCache.getAllObjects(monitor, SQLServerSchema.this)) {
-                if (table.getObjectId() == tableId && table instanceof SQLServerTable) {
-                    return (SQLServerTable) table;
-                }
-            }
-            log.debug("Table '" + tableId + "' not found in schema " + getName());
-            return null;
-        }
-
         @Nullable
         @Override
         protected SQLServerTableForeignKeyColumn[] fetchObjectRow(