Issue after upgrading to latest stable versions of EpiServer nuget packages



After upgrading to all Episerver nuget packages to latest stable versions of CMS12, we are seeing a casting issue:

      Message=Unable to cast object of type 'Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DisplayMetadata' to type 'EPiServer.Shell.ObjectEditing.ExtendedMetadata'.

Sample Code:

namespace KK.Opti.Common.Menu.Infrastructure.Attributes
    public class PropertyListLinkAttribute : Attribute, IMenuModelMetadataAware
        public Injected<IUrlResolver> UrlResolver { get; set; }
        public Dictionary<string, string> LinkMappings { get; set; }

        public virtual void OnMetadataCreated(DisplayMetadata metadata)
            var extendedMetadata = (ExtendedMetadata)metadata;

            var list = ((MenuItemProperty)extendedMetadata.Model).List;


Any help is appreciated.

Edited, Jan 13, 2023 0:31

Shot in the dark here, try removing the interface and include the following using 

    using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;

After some reading 

"One thing that has been removed in MVC6 is the IMetadataAware interface. This allowed you to create your own subclasses of Attribute that could add data to the ModelMetadata structure to be used in an EditorTemplate or DisplayTemplate view." 

See more info here : Reinstating IMetadataAware in ASP.NET 5 vNext MVC 6 ( 

Jan 13, 2023 1:51

We are doing exactly how that link suggests. The code was working until we just updated EpiServer nuget pkgs to latest stable versions.

Jan 13, 2023 16:58
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.