Using Umbraco ModelsBuilder

Firstly, make sure the following properties are set in your solution’s top-level web.config to enable the models builder:

<add key="Umbraco.ModelsBuilder.Enable” value="true”/>
<add key="Umbraco.ModelsBuilder.ModelsMode” value="LiveAppData”/>


I like the “LiveAppData” mode, but you should experiment with the others from the list in the ModelsBuilder docs here.  Generate your model classes, and include them in the VS Solution.

Unless you’re on a brand new project, any existing views will need to be modified.

Model class inheritance

Change instances of
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
to
@inherits Umbraco.Web.Mvc.UmbracoViewPage<ContentModels.ModelName>

Property Access

Change instances of
@Umbraco.Field(“propertyAlias”)
to
@Model.PropertyAlias
Note that the ModelsBuilder converts property aliases to PascalCase instead of camelCase

Rendering Grid HTML

Change instances of
@CurrentPage.GetGridHtml(“gridProperty”)
to
@Html.GetGridHtml(Model, “gridProperty”)

Getting URLs for Image Properties

No more passing around image IDs or calling Umbraco.TypedMedia!  Make sure you can use C# 6 language features (Install-Package Microsoft.Net.Compilers) and just do this:
String imageUrl = Model.ImageProperty?.Url;