Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Recently I took a look at Umbraco.ModelsBuilder.Api and I wanted to try and create a separate class library to segregate my models.
I've been following this very helpful guide: https://24days.in/umbraco-cms/2016/getting-started-with-modelsbuilder/
But I'm a bit stuck. It seems as though ModelsBuilder can't find my generated classes which are in their own library. Here's my WebConfig:
<add key="Umbraco.ModelsBuilder.Enable" value="true" /> <add key="Umbraco.ModelsBuilder.ModelsMode" value="Nothing" /> <add key="Umbraco.ModelsBuilder.EnableApi" value="true" /> <add key="Umbraco.ModelsBuilder.ModelsNamespace" value="Umbraco7102.Library.Models"/> <add key="Umbraco.ModelsBuilder.ModelsDirectory" value="~/Umbraco7102.Library/Models"/> <add key="Umbraco.ModelsBuilder.AcceptUnsafeModelsDirectory" value="true"/>
/Umbraco7102.Library/Models is where my generated classes are, however I'm being given this message:
The type or namespace name 'Home' does not exist in the namespace 'Umbraco.Web.PublishedContentModels' (are you missing an assembly reference?)
It throws the error on this line:
public class _Page_Views_Home_cshtml : Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Home>
I'm referencing my class library in my Umbraco project, and I've named my generated class builder "UmbracoModels.cs".
Any help would be much appreciated!
Hi Alex,
The issue is probably in your view.
This is pointing to ContentModels namespace
Can you change your view to start with this statement
@inherits UmbracoViewPage<Umbraco7102.Libray.Models.Home>
Dave
Thanks Dave, that was simple... I think I had tunnel vision
I feel like a fool.
Thank you!
No problem...have seen that error myself multiple times.
dave
I noticed something which I think threw me off at first.
It seems ModelsBuilder removes the period in my class library when generating the models, as they turn out like the following:
namespace Umbraco7102Library.Models { /// <summary>File</summary> [PublishedContentModel("File")] public partial class File : PublishedContentModel { } }
Even though my builder is in the following namespace:
namespace Umbraco7102.Library.Models
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco.ModelsBuilder.Api Cannot Find Namespace
Recently I took a look at Umbraco.ModelsBuilder.Api and I wanted to try and create a separate class library to segregate my models.
I've been following this very helpful guide: https://24days.in/umbraco-cms/2016/getting-started-with-modelsbuilder/
But I'm a bit stuck. It seems as though ModelsBuilder can't find my generated classes which are in their own library. Here's my WebConfig:
/Umbraco7102.Library/Models is where my generated classes are, however I'm being given this message:
It throws the error on this line:
I'm referencing my class library in my Umbraco project, and I've named my generated class builder "UmbracoModels.cs".
Any help would be much appreciated!
Hi Alex,
The issue is probably in your view.
This is pointing to ContentModels namespace
Can you change your view to start with this statement
Dave
Thanks Dave, that was simple... I think I had tunnel vision
I feel like a fool.
Thank you!
No problem...have seen that error myself multiple times.
dave
I noticed something which I think threw me off at first.
It seems ModelsBuilder removes the period in my class library when generating the models, as they turn out like the following:
Even though my builder is in the following namespace:
is working on a reply...