Search code examples
umbracoumbraco7

Generated models property type changes after updating to latest version Umbraco 7


I've got an Umbraco site in Visual Studio that uses the generated Umbraco.Web.PublishedContentModels.dll for its models. I'm trying to update this site from 7.5.6 to the latest version of Umbraco 7 (7.15.5). Along with the updated Umbraco CMS Nuget package, I get the updated Umbraco.ModelsBuilder 3.0.10.

Everything seems OK, but when I try to regenerate the Umbraco.Web.PublishedContentModels.dll through the backend, the generated DLL has different property types for certain models. Mostly it's properties that used to be strings, that are now IPublishedContent. For instance, I've got a Document Type "Meal" that has a Media field "Photo". Photo used to be a string, but it's now Umbraco.Core.Models.IPublishedContent.

I inherited this site recently, so I'm not really sure how the type of the Photo property was generated as string to begin with. Has there been a change between 7.5 and 7.15 in how models are generated? Or was some configuration broken?

I guess I can rewrite each place where these properties are used to unwrap the IPublishedContent and get the right property out, but it'd be a lot of work that I would rather avoid.


Solution

  • Umbraco team added value converters to all built-in data types in v7.6.

    Value converters can be disabled in ~/config/umbracoSettings.config:

    <!-- Enables value converters for all built in property editors so that they return strongly typed object, recommended for use with Models Builder -->
    <EnablePropertyValueConverters>true</EnablePropertyValueConverters>
    

    You can find more details here: https://issues.umbraco.org/issue/U4-7318