https://discord.umbraco.com logo
#help-with-umbraco
Make ModelsBuilder use MediaPicker (legacy)
# help-with-umbraco
h

halfwat

10/17/2023, 2:24 PM
We've migrated a site from v7 to v8 and modelsbuilder cannot resolve any media as the model code is attempting to resolve media via Udi and all the properties are using the legacy integer id. Is it possible to configure ModelsBuilder to resolve using the legacy id?
a

abjerner

10/17/2023, 2:44 PM
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.
h

halfwat

10/17/2023, 2:48 PM
> 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 Is there a way to automate this? I'm erring towards using a property value convertor as this site is likely to be completely rebuilt
a

abjerner

10/17/2023, 3:04 PM
> Is there a way to automate this? not out of the box - it involves using the content service for converting the affected values and republishing the pages
h

halfwat

10/17/2023, 3:05 PM
mm I suspected this, not totally against it
thank you for your insight @abjerner
u

_tommadden

11/07/2023, 9:40 AM
It might be worth looking at the Migration package created by ProWorks https://www.proworks.com/blog/archive/how-to-upgrade-umbraco-version-7-to-version-8/
2 Views