Copied to clipboard

Flag this post as spam?

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


  • Chris 32 posts 108 karma points
    Oct 07, 2021 @ 09:08
    Chris
    0

    Umbraco v9 - Unable to publish due to missing namespace in Umbraco.Cms.Web.Common.PublishedModels

    Hi,

    Just trying to publish our first site in v9. Getting the following error

    The type or namespace name 'AboutDT' does not exist in the namespace 'Umbraco.Cms.Web.Common.PublishedModels' (are you missing an assembly reference?)

    Have the templates set up as

    @using ContentModels = Umbraco.Cms.Web.Common.PublishedModels
    @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage<ContentModels.AboutDT>
    

    Works locally using InMemoryAuto but fails on publish. I have tried the different ModelsBuilder ModelsMode in the appsettings.json but both SourceCodeManual and SourceCodeAuto now fail to build locally with the same "namespace does not exist" error so not generating any models in "umbraco/models" folder

    What am I doing wrong? Thanks.

  • Chris 32 posts 108 karma points
    Oct 19, 2021 @ 12:35
    Chris
    0

    Anyone please?

    This is what the Models builder tab says

    enter image description here

    Thanks.

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Oct 19, 2021 @ 13:00
    Warren Buckley
    101

    Hi Chris 👋

    I would suggest SourceCodeAuto or SourceCodeManual ModelsBuilder mode.

    This will then allow you to generate C# Models on disk that can be part of the build compilation.

    With the setting changed to SourceCodeAuto anytime a new property is added or a document type is changed then it will generate the C# models for you.

    If you prefer the Manual mode then you will need to visit the dashboard in the backoffice and click the button to generate them.

    If you are to do this on your local development machine for this setting, then you can version control the C# Models and when doing a dotnet publish or deployment to your live site the C# models will be part of the build and should not give you this error you are seeing.

    Thanks
    Warren 😃

  • Chris 32 posts 108 karma points
    Oct 19, 2021 @ 13:24
    Chris
    1

    Hi Warren,

    Thanks for the pointers.

    Got it working with SourceCodeManual by going directly to /umbraco#/settings?dashboard=settingsModelsBuilder, clicking 'Generate models' and then restarting the project to pick up the .generated.cs models in the /umbraco/models folder.

    It appears you still have to do that with the Auto option too but I presume once generated it keeps the models upto date, as you say, although I thought it would have also auto generate the models for you on start on the first time too.

    Got it published so that is great. Thanks.

  • Ayod El Modai Arune 1 post 71 karma points
    Dec 01, 2021 @ 19:25
    Ayod El Modai Arune
    0

    Hi!

    I can't find Generate models button on this pathenter image description here

  • Chris Clancy 64 posts 133 karma points
    Feb 21, 2022 @ 13:47
    Chris Clancy
    0

    See https://our.umbraco.com/documentation/reference/templating/modelsbuilder/configuration.

    In appsettings.json, make sure modelsbuilder included.

    "Umbraco": {
    "CMS": {
      "Hosting": {
        "Debug": false
      },
      "ModelsBuilder": {
        "ModelsMode": "SourceCodeManual"
      }
    }
    

    }

  • Warren Buckley 2106 posts 4836 karma points MVP 7x admin c-trib
    Oct 19, 2021 @ 13:29
    Warren Buckley
    0

    Glad you got it resolved then :)

Please Sign in or register to post replies

Write your reply to:

Draft