Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gibran Shah 69 posts 240 karma points
    Mar 10, 2019 @ 18:21
    Gibran Shah
    0

    all.generate.cs and models.generate.cs failing to generate

    Hello,

    I'm getting this strange error here:

    enter image description here

    It's telling me it can't find 'Home' in the namespace 'Umbraco.Web.PublishedContentModels'.

    I did a search in my project for all instances of PublishContentModels. I found a lot of references to it but no definition.

    Find all "PublishedContentModels", Subfolders, Find Results 1, Entire Solution, ""
      C:\repos\hab4\Holland and Barnes\Views\AboutUs.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\AccountLogin.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\AirportLiaison.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\Blog.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\Blogpost.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\Contact.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\ContentPage.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\Employment.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\EmploymentPosting.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\Feedback.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\Home.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\LimoService.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\Listing.cshtml(23):                @foreach (Umbraco.Web.PublishedContentModels.Service service in services)
      C:\repos\hab4\Holland and Barnes\Views\Partials\MacroPartials\LatestBlogposts.cshtml(1):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\People.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\ReferAFriend.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\Service.cshtml(4):    Umbraco.Web.PublishedContentModels.Service service = (Umbraco.Web.PublishedContentModels.Service)Model.Content;
      C:\repos\hab4\Holland and Barnes\Views\Service.cshtml(118):                        @foreach (Umbraco.Web.PublishedContentModels.OperatingHours OperatingHours in service.OperatingHours)
      C:\repos\hab4\Holland and Barnes\Views\VIPCard.cshtml(2):@using ContentModels = Umbraco.Web.PublishedContentModels;
      C:\repos\hab4\Holland and Barnes\Views\Web.config(23):                <add namespace="Umbraco.Web.PublishedContentModels" />
      Matching lines: 20    Matching files: 19    Total files searched: 235
    

    Usually, the project consists of a couple files in which all the models are defined:

    .../AppData/Models/all.generated.cs .../AppData/Models/models.generated.cs

    I assume this is where the namespace would be and where Home is defined. However, I'm not finding the Models folder in my AppData folder. Is there are reason the model files would fail to generate?

  • Chris Evans 137 posts 353 karma points c-trib
    Mar 10, 2019 @ 22:39
    Chris Evans
    0

    Hi Gibran,

    Are you using the AppData mode for Models Builder? Do you have this key value in your web.config:

    <add key="Umbraco.ModelsBuilder.ModelsMode" value="AppData" />
    

    If so, you need to manually generate the models by going into the Developer section, click on the Models Builder tab, and hit the red "Generate models" button.

    This should cause Umbraco to create the Home.cs file and add it to your AppData folder.

    Note you'll also want to include that new file into your solution and build before running the website on the frontend again.

    In future if you make further changes to the document type, or add new ones, you'll want to Generate models again, include any new files, and rebuild.

    Hope this helps,

    Chris

Please Sign in or register to post replies

Write your reply to:

Draft