Extending the Modelsbuilder Models
# help-with-umbraco
p
Hey everyone, i'm currently struggling with the modelsbuilder. My problem is that i have a class BusinessArea which is generated from the modelsbuilder. But when i create a partial class named BusinessArea which should extend the generated one, it does not work / recognize. Where could the problem be?
s
Maybe you should use your own namespace and not try to put it in Umbraco's namespace. This will add an extra
using
where you need it but that shouldn't be a problem.
p
Hey @Sebastiaan Thanks for your Reply. When i put it in a separate namespace it won't find the property Name:
m
What models builder mode are you using?
p
@Matt Wise I'm using the standard version.
Umbraco 10
s
p
Sorry bout that... this is my config 🙂 "ModelsBuilder": { "ModelsMode": "SourceCodeAuto", "FlagOutOfDateModels": true },
a
How does your solution look? Do you have just a single project, or do you have more than one? We typically have a code project and a web project. The two parts of a partial class needs to be in the same project.
p
We just have one solution currently. The new extending class is inside the /models/businessArea.cs
m
And are the generated models in the same project?
p
yes they are in the same project
/umbraco/models
m
Sounds like it should be working no spelling mistakes in the class name?
p
no there are no spelling mistakes :/
This is correct? namespace MD.Multicolorprint.Multicolorsites.Umb.Models;
m
You will want to match the models builder classes namespace
Hot reload won't pick it up so you will need to rebuild
p
Matt this was the final hint! 🙂 Thanks alot it works now 🙂 i've already used this namespace but i didn't know that the hot reload dont works 😦
2 Views