Copied to clipboard

Flag this post as spam?

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


  • Hassan 79 posts 264 karma points
    Jul 05, 2021 @ 15:12
    Hassan
    0

    Cannot bind source content type Umbraco content model to view model

    Hi every one!

    I use Umbraco 7.9.2. I implemented a Blog page and some Blog Posts in it by create child nodes in Blog page.

    This is Blog Posts template:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.BlogPost>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
            Layout = "MasterPage.cshtml";
            ...
    }
    ...
    

    And this is Blog template:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Blog>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
            Layout = "MasterPage.cshtml";
            ...
    }
    ...
    

    And this is MasterPage template:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @using Umbraco.Core;
    @using ClientDependency.Core.Mvc;
    @{
            Layout = null;
            ...
    }
    ...
    

    I sometimes get "Cannot bind source content type Umbraco.Web.PublishedContentModels.BlogPost to model content type Umbraco.Web.PublishedContentModels.BlogPost. Both view and content models are PureLive, with same version. The application is in an unstable state and should be restarted." exception when I go to Blog posts page or Blog page. In this exception both view and content models are the same.

    I clear cache by click on Republish entire site and save related Document Types and Templates to Blog and BlogPosts, but I sometimes get this exception again.

    What is the problem? How can I solve this boring exception?

    With thanks.

  • Nik 1614 posts 7260 karma points MVP 7x c-trib
    Jul 05, 2021 @ 16:21
    Nik
    1

    Hi Hassan,

    I believe you have switched from PureLive to AppData/Dll mode for Models Builder.

    This will leave some files in the App_Data directory (I'm sorry I can't recall the exact path). I think they are called something like all.generated.cs or something similar to that. You will need to delete that file if it's present and then try again.

    The error is telling you that the model existings in two locations and it doesn't know which to use.

    Thanks

    Nik

  • Hassan 79 posts 264 karma points
    Jul 10, 2021 @ 08:11
    Hassan
    0

    Hi Nik,

    Thanks for your reply.

    I deleted all.generated.cs and model.generated.cs files in App_Data/Models folder and switched from PureLive to AppData and push Generate models button in developer section. After that models generated in App_Data/Models, but an exception occured when I run my site. exception is "The type or namespace name 'Home' does not exist in the namespace 'Umbraco.Web.PublishedContentModels' (are you missing an assembly reference?)'".

    Please see this image:

    enter image description here

    What is the problem? How can I solve this exception?

    With thanks.

Please Sign in or register to post replies

Write your reply to:

Draft