Copied to clipboard

Flag this post as spam?

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


  • MB 259 posts 910 karma points
    Oct 19, 2021 @ 13:44
    MB
    0

    Moving to Umbraco 9 - Models fails (does not contain a definition of X)

    I've installed Umbraco 9 and successfully migrated all pages from Umbraco 8 to the new version.

    I have also moved all my Models to the new Umbraco 9 but they all fail as you can see in the image.

    I tried to clone to Vendr Umbraco 9 version and pasted all their models (including the generated ones) to my project but they still fail.

    Is it because I somehow need to rebuild the models and if so, how can I do this when I'm not able to boot into Umbraco backend?

    My ModelsBuilder looks like this:

     "ModelsBuilder": {
        "Enable": true,
        "ModelsMode": "SourceCodeManual",
        "ModelsDirectory": "~/Vendr/Models",
        "ModelsNamespace": "Vendr.Models",
        "AcceptUnsafeModelsDirectory": true
      },
    

    enter image description here

  • Warren Buckley 2106 posts 4789 karma points MVP โˆž admin hq c-trib
    Oct 20, 2021 @ 08:47
    Warren Buckley
    1

    Hi MB ๐Ÿ‘‹

    Are you able to run the Umbraco site regardless of these errors?

    I would try doing a dotnet run from the terminal inside the project that contains the Umbraco 9 website/project.

    Yes the initial request of the frontend may error, but I would be curious if you are then able to browse to /umbraco backoffice and then goto the settings section and Models Builder tab to recreate the generated.cs models.

    Let us know if that approach works or not and see what we can do to help get you back up and running..

    Cheers,

    Warren ๐Ÿ˜€

  • MB 259 posts 910 karma points
    Oct 21, 2021 @ 05:15
    MB
    0

    Hi Warren,

    Thank you for reaching back to me, I appreciate that a lot!

    I tried the dotnet run and it returns a different list of errors but, pretty much the same:

    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Models\SearchPage.generated.cs(23,36): error CS0246: The type or namespace name 'Page' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Extensions\PublishedContentExtensions.cs(18,23): error CS0246: The type or namespace name 'HomePage' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Extensions\PublishedContentExtensions.cs(33,55): error CS0246: The type or namespace name 'IProductComp' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Extensions\PublishedContentExtensions.cs(38,60): error CS0246: The type or namespace name 'IProductComp' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Extensions\PublishedContentExtensions.cs(43,60): error CS0246: The type or namespace name 'IProductComp' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Extensions\PublishedContentExtensions.cs(43,82): error CS0246: The type or namespace name 'IProductComp' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Extensions\PublishedContentExtensions.cs(48,49): error CS0246: The type or namespace name 'IProductComp' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Models\CategoryCollectionPage.cs(9,16): error CS0246: The type or namespace name 'CollectionPage' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Extensions\PublishedContentExtensions.cs(53,49): error CS0246: The type or namespace name 'IProductComp' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Extensions\PublishedContentExtensions.cs(53,71): error CS0246: The type or namespace name 'IProductComp' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Models\CheckoutConfirmationPage.cs(8,39): error CS0115: 'CheckoutConfirmationPage.Order': no suitable method found to override [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Models\Forside.cs(8,16): error CS0246: The type or namespace name 'SearchPage' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Models\Forside.cs(14,28): error CS0246: The type or namespace name 'CategoriesPage' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Models\ProductPage.cs(9,16): error CS0246: The type or namespace name 'CollectionPage' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Models\CheckoutReviewPage.cs(6,47): error CS0535: 'CheckoutReviewPage' does not implement interface member 'IOrderReviewPage.Order' [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\Vendr\Models\ProductPage.cs(13,28): error CS0246: The type or namespace name 'ProductVariant' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\Mikes\RiderProjects\vendr_9\RSCS9\RSCS9.csproj]
    dotnet : 
    At line:1 char:1
    + dotnet run
    + ~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError
    
    The build failed. Fix the build errors and run again.
    PM> 
    

    If I ignore these errors and boot up Umbraco with the last successful build I get the following error which prevents me from accessing the backend to build the models.

    HTTP Error 500.0 - ANCM In-Process Handler Load Failure 
    

    Just, out of curiosity. Could it be a setting in the .csproj file? My file looks like the:

    <Project Sdk="Microsoft.NET.Sdk.Web">
    
        <PropertyGroup>
            <TargetFramework>net5.0</TargetFramework>
            <DefaultItemExcludes>$(DefaultItemExcludes);App_Plugins/**;</DefaultItemExcludes>
            <DefaultItemExcludes>$(DefaultItemExcludes);umbraco/**;</DefaultItemExcludes>
            <DefaultItemExcludes>$(DefaultItemExcludes);wwwroot/media/**;</DefaultItemExcludes>
        </PropertyGroup>
    
        <ItemGroup>
            <PackageReference Include="Umbraco.Cms" Version="9.0.1" />
            <PackageReference Include="Vendr" Version="2.0.0" />
        </ItemGroup>
    
        <ItemGroup>
            <Content Include="App_Plugins/**" CopyToOutputDirectory="Always" />
            <Content Include="umbraco/**" CopyToOutputDirectory="Always" />
            <Content Remove="umbraco/Data/**" />
            <Content Remove="umbraco/Logs/**" />
            <Content Remove="umbraco/mediacache/**" />
            <Content Remove="umbraco/models/**" />
            <Compile Include="umbraco/models/**" Exclude="**/*.flag" />
        </ItemGroup>
    
        <!-- Set this to true if ModelsBuilder mode is not InMemoryAuto-->
        <PropertyGroup>
            <RazorCompileOnBuild>true</RazorCompileOnBuild>
            <RazorCompileOnPublish>true</RazorCompileOnPublish>
        </PropertyGroup>
    
    </Project>
    
  • Gogo Dev 30 posts 163 karma points
    Oct 27, 2021 @ 14:38
    Gogo Dev
    0

    Are your models in a different folder than your project is? Do you need to explicitly add a ModelsNamespace key to your appsettings.json? (I mean if it is a requirement of vendr or something, cause I'm not familiar with vendr)

  • Jörg Seibert 10 posts 61 karma points
    Oct 28, 2021 @ 08:32
    Jรถrg Seibert
    0

    I would not ignore these compile errors, they seem to break a lot of stuff here.
    At first glance I guess your models aren't created yet. You might want to not compile razor before models are created.
    Try to start project with <RazorCompileOnBuild>false</RazorCompileOnBuild> <RazorCompileOnPublish>false</RazorCompileOnPublish>

    If that helps running Umbraco Backoffice, rebuild your Models in ModelsBuilder tab in settings.

    Otherwise exclude Vendr from project, start project to test if it works. If so add package again, check if all references and namespaces are correct and compile without errors.
    On success you should be able to run your site.

    hth

Please Sign in or register to post replies

Write your reply to:

Draft