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
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.
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.
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
Have the templates set up as
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.
Anyone please?
This is what the Models builder tab says
Thanks.
Hi Chris 👋
I would suggest
SourceCodeAuto
orSourceCodeManual
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 😃
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.
Hi!
I can't find Generate models button on this path
See https://our.umbraco.com/documentation/reference/templating/modelsbuilder/configuration.
In appsettings.json, make sure modelsbuilder included.
}
Glad you got it resolved then :)
is working on a reply...