Adding custom model throws error

I’m using Umbraco 10. I create a Customer Document type with some fields i need to have for that page (something the content writers would enter)

On this page i have a few custom fields that i need to capture from the end user and then do a post on the form.

I create a custom customer model and add

@Html.LabelFor(c=> c.Name)

and it throws an error that the property cant be found. I then add a declaration to the top

@model Models.Customer

This resolves the above error but when the page loads it throws the error

ArgumentException: Property ‘ViewData’ is of type ‘Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary1[[Umbraco.Cms.Web.Common.PublishedModels.Customer, CustomModels, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]', but this method requires a value of type 'Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary1[[Customer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]’. (Parameter ‘viewContext’)

The controller it calls is inheriting from SurfaceController.

Whats going wrong here?


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/113281-adding-custom-model-throws-error