Currently we rely on SQL Server behaviour in merge and custom ordering, which is very fragile in some scenarios (for example duplicate values in database). We should use artificial column to map original index to database generated identity.