What's new in Umbraco v9? We still have our friend Models Builder, but now there are some configuration changes. Let's have a look...
What is Models Builder?
Using Models Builder we can generate strongly types models in Umbraco to use our Umbraco doctype properties as if they have been added to a good old C# class.
What has changed in v9?
First of all, this is now configured in appsettings.json rather than in web.config XML. This is in keeping with the changes made more generally in .Net Framework to .Net Core development. See example:
The main difference in configuration options from v8 to v9 is the naming of the options in ModelsMode:
- PureLive is now InMemoryAuto: Generate the models dynamically in memory.
- AppData is now SourceCodeManual: Generate the models to be stored in source code when a CMS user selects "GenerateModels" in the backoffice.
- LiveAppData is now SourceCodeAuto: Generate the models to be stored in source code automatically when a doctype change occurs.
How can we configure Models Builder?
In our appsettings.json we can configure Models Builder settings. For example:
- ModelsNamespace: What do you want the name space of your model classes to be? Set it here. Note: if unset, the default is Umbraco.Web.Common.PublishedModels
- ModelsDirectory: You can choose the folder in the repo the generated models are stored. For example "~/Models/Umbraco"
-
AcceptUnsafeModelsDirectory: Set this to true if you want to allow unsafe directories, for example if the models directory to be outside the Web project
you can see full configuration details here.