References class File which doesn't exist

SS 4.0

Hi Im trying to migrate my silverstripe build to version 4.0, all going well so far but trying to migrate an image upload field to one of my page template but getting this error:

Uncaught InvalidArgumentException: has_one relation ContactPage.HQMarker references class File which doesn’t exist

‘HQMarker’ => ‘Image’,

and declaring the field below as:

$fields->addFieldToTab(‘Root.GoogleMap’, new UploadField(‘HQMarker’,‘Head Quaters Place Marker’));

Rest of the fields on the page work fine apart from image fields

It’s a bit difficult without seeing the rest of your code, but a possibility:

Change the relation to 'HQMarker' => Image::class

Make sure you have a corresponding use statement at the top of the file (eg. use SilverStripe\Assets\Image;)

Do a dev/build and see if the issue remains.

That works now, thankyou!