Search code examples
c#asp.net.netumbraco

Why am I getting 'Model' does not contain a definition for 'oTitle' CS1061 Umbraco (12.3.4)?


I working on an umbraco project (12.3.4), and have the OskiStarterKit(3.0.2) installed

I created a Documenttype with a Template and added some compistions, and put some content in it, i have also genrated the models after that.

This is my Product.cshtml

@using Umbraco.Cms.Web.Common.PublishedModels;
@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.Product>
@using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;
@{
    Layout = null;
}

    <!DOCTYPE html>
<html>
<head>
    <title>@Model.oTitle</title>
</head>

And the property name "oTitle" is the same on the generated published product model

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder.Embedded", "12.3.4+4a0d364")]
        [global::System.Diagnostics.CodeAnalysis.MaybeNull]
        [ImplementPropertyType("oTitle")]
        public virtual string OTitle => global::Umbraco.Cms.Web.Common.PublishedModels.OCardsContainer.GetOTitle(this, _publishedValueFallback);

The namespace of the generated model is namespace Umbraco.Cms.Web.Common.PublishedModels Everything seems to be fine, but for some reason im getting this error:

'Product' does not contain a definition for 'oTitle' and no accessible extension method 'oTitle' accepting a first argument of type 'Product' could be found (are you missing a using directive or an assembly reference?)

What could be the issue?


Solution

  • oTitle is the alias of the property, but your model property generates with PascalCase and not camelCase :-) So you should be able to do @Model.OTitle instead?