This isn't related to Models Builder, but the property value converter of the property editor that you're using.
To bring your data up to date with Umbraco 8 and newer versions, it might be best to convert your data so that the references are saved as UDIs rather than numeric IDs.
If this isn't feasible, you could try to replace Umbraco's property value converter for the legacy media picker with your own. You can find the source code for Umbraco's here:
https://github.com/umbraco/Umbraco-CMS/blob/release-8.18.9/src/Umbraco.Web/PropertyEditors/ValueConverters/MediaPickerValueConverter.cs
Notice line 15 - you shouldn't include this line as you'd otherwise run into problems with multiple value converters for the same property editor.
But the rest of the class should be good to copy to project, and you can then update the different bits from handling UDIs to handling numeric IDs instead.