Umbraco.Community.ModelsBuilder.PropertyOverride 15.0.0

dotnet add package Umbraco.Community.ModelsBuilder.PropertyOverride --version 15.0.0
                    
NuGet\Install-Package Umbraco.Community.ModelsBuilder.PropertyOverride -Version 15.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Umbraco.Community.ModelsBuilder.PropertyOverride" Version="15.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Umbraco.Community.ModelsBuilder.PropertyOverride" Version="15.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Umbraco.Community.ModelsBuilder.PropertyOverride" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Umbraco.Community.ModelsBuilder.PropertyOverride --version 15.0.0
                    
#r "nuget: Umbraco.Community.ModelsBuilder.PropertyOverride, 15.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Umbraco.Community.ModelsBuilder.PropertyOverride&version=15.0.0
                    
Install Umbraco.Community.ModelsBuilder.PropertyOverride as a Cake Addin
#tool nuget:?package=Umbraco.Community.ModelsBuilder.PropertyOverride&version=15.0.0
                    
Install Umbraco.Community.ModelsBuilder.PropertyOverride as a Cake Tool

Umbraco.Community.ModelsBuilder.PropertyOverride

Downloads NuGet GitHub license

This package re-introduces functionality for overriding ModelsBuilder property implementations that was lost in Umbraco 9+.

Umbraco versions 15.x are supported.

Properties can be marked up with a re-implemented [ImplementPropertyType("alias")] attribute, which causes them to be ignored when generating models through the default ModelsBuilder.

In addition, classes can be marked up with [ImplementAllPropertyTypes], which causes all properties on the class to be ignored, this is functionally equivalent to adding [ImplementPropertyType("alias")] to every property on the class.

Legacy (Umbraco 8.x) documentation for the [ImplementPropertyType("alias")] attribute can be found here.

Examples

[ImplementPropertyType("alias")] to ignore properties on an individual basis:

using Umbraco.Cms.Infrastructure.ModelsBuilder;

namespace ModelsBuilder.PropertyOverride.TestSite.Models
{
    public partial class Home
    {
        [ImplementPropertyType("content")]
        public global::Umbraco.Cms.Core.Models.Blocks.BlockListModel Content => this.Value<global::Umbraco.Cms.Core.Models.Blocks.BlockListModel>(_publishedValueFallback, "content");

        [ImplementPropertyType("title")]
        public virtual string Title => this.Value<string>(_publishedValueFallback, "title");
    }
}

[ImplementAllPropertyTypes] to ignore all properties:

using Umbraco.Cms.Infrastructure.ModelsBuilder;

namespace ModelsBuilder.PropertyOverride.TestSite.Models
{
    [ImplementAllPropertyTypes]
    public partial class HomePageBlock 
    {
        public virtual global::Umbraco.Cms.Core.Models.MediaWithCrops Image { get; set; }
        public virtual string SubTitle { get; set; }
        public virtual string Title { get; set; }
    }
}

Installation

Add the package to an existing Umbraco website (Umbraco 15.x) from nuget:

dotnet add package Umbraco.Community.ModelsBuilder.PropertyOverride

Contributing

Contributions to this package are most welcome!

Acknowledgments

tristanjthompson & zade107

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
15.0.0 206 3/6/2025
13.0.0 203 3/6/2025
1.0.1 211 3/6/2025
1.0.0 201 3/6/2025