Umbraco 13 ModelsBuilder - Ignore Properties and c...
# help-with-umbraco
p
I am working on a migration from v7 to v13 and have discovered there no longer appears to be the same level of support for customisation of model generation that there used to be. For instance we used to use the
[IgnorePropertyType("PropertyAlias")]
on our partial classes to prevent generation of properties when we needed to. I note in the current docs for v13 it states... "*Models builder does not take a custom partial class into account when generating the models. This means that if a custom partial class, inherits from a base class, tries to provide a constructor with the same signature, or implements a generated property, it will cause compilation errors.*" This also means that any properties we explicitly define in our own partial classes are not considered when generating models which results in duplication of properties and therefore compilation errors. The docs also state... > For more complex partial classes, you'll have to use the full version of the Models Builder. This doesn't seem like a viable solution given how old/stale the project now is. How are others handling these issues currently?
j
This looks good, though I've yet to use it. https://github.com/limbo-works/Limbo.Umbraco.ModelsBuilder There's a bit of a discussion here that's releated: https://github.com/umbraco/Umbraco-CMS/discussions/11854 I've been meaning for a while to start pulling together a PR to add new features to modelsbuilder, but I don't miss the old functionality as much as I used to. For custom property values, I've found the best (and possibly technically/paradigmatically the most "correct") approach is to use a custom PropertyValueConverter to override the actual property value that modelsbuilder uses. You can make use of the PropertyCacheLevel, use DI to pull in services etc. if necessary, and you can inherit from Umbraco's built-in converters to avoid too much boilerplate. For simpler things like
Property => FormatDifferently(this.SomeOtherProperty);
I just live with the fact that there's redundant properties in my models these days.
p
> I've been meaning for a while to start pulling together a PR to add new features to modelsbuilder, but I don't miss the old functionality as much as I used to. That'a good point, perhaps I should look at doing that. I unfortunately do miss some of the old functionality. > I just live with the fact that there's redundant properties in my models these days. I've got issues and think that will keep bothering me. 🫣 Thanks for the heads up on Limbo Models Builder I will give that a look.
d
Currently using Limbo on an Umbraco Cloud Project and so far it has been trouble free.
p
@Dean Leigh Out of interest - what prompted you to use that over the Core ModelsBuilder?
d
It was already in a client site but I can ask them
OK so I have run into an issue with Limbo Models Builder this week. I installed Block Preview and it was returning a blank preview. @rickbutterfield kindly jumped on the call and identified that his package is designed to work with Umbraco's native models builder. This did make me wonder if there are other packages that rely on it.
24 Views