Copied to clipboard

Flag this post as spam?

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


  • Kris Janssen 210 posts 568 karma points c-trib
    Jun 21, 2017 @ 01:17
    Kris Janssen
    0

    Inability to use AppData ModelsBuilder mode on UaaS?

    Hi,

    I followed the official documentation to generate a VS solution for my Umbraco Cloud project using UaaS.cmd, which in turn downloads Waasp.exe.

    The .Web project is essentially added to the solution as a website, not a real project.

    This is messing with the ability to work with ModelsBuilder in AppData mode:

    <add key="Umbraco.ModelsBuilder.Enable" value="true"/>
    <add key="Umbraco.ModelsBuilder.ModelsMode" value="AppData"/>
    

    And web.config in the views folder:

    <system.web.webPages.razor>
        <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <pages pageBaseType="System.Web.Mvc.WebViewPage">
          <namespaces>
            ...
            <add namespace="Umbraco.Web.PublishedContentModels" />        
          </namespaces>
        </pages>
     </system.web.webPages.razor>
    

    While the code files are in the correct folder, they have no effect because, afaik, VS probably does not see them in the website (it is not looking for things to compile?)

    Solution view of Models

    Even so, this is what my views tell me:

    Model not found

    Also, the application does not run locally:

    enter image description here

    In PureLive, everything is perfectly fine...

    Does all this mean you will never be able to work in AppData mode in Umbraco Cloud? Is it safe to enable dll mode instead but then, what happens when you commit and push?

    Any help would be greatly appreciated :)

  • Søren Kottal 410 posts 2504 karma points MVP c-trib
    Jun 21, 2017 @ 06:32
    Søren Kottal
    0

    Hi Kris

    For AppData mode to work in a website project, you must either generate the models in another project which you then build a dll for in your website, or generate them in App_Code.

    To generate them in other places than App_Data/Models, you need to add these config keys:

    <add key="Umbraco.ModelsBuilder.AcceptUnsafeModelsDirectory" value="true"/> <!-- only needed if modelsDirectory is outside website dir -->
    <add key="Umbraco.ModelsBuilder.ModelsDirectory" value="~/App_Code/Models" />
    

    This will generate your models in App_Code, where you don't need to build.

    You can also set ModelsDirectory to eg. ~/../chemtech.Core/Models and have them built there. Then you can also use your models in your core library. For this to work, you need AcceptUnsafeModelsDirectory to be true.

    We use (Live)Dll mode, as we don't want to have to manually build models, and also we want to be able to use them in our core library.

  • Kris Janssen 210 posts 568 karma points c-trib
    Jun 21, 2017 @ 14:10
    Kris Janssen
    0

    Hi Søren,

    Thanks for the update.

    I actually already tried your suggestion of actually putting the generated code in App_Code but then again because it is a website to VS, you run into issues as some of the generated code references things from Umbraco:

    [PublishedContentModel("home")]
    public partial class Home : PublishedContentModel, IContentGrid, IContentSlider, IMetaTitle
    

    Things like IContentGrid, ... are not found when trying to start the website. Also, I am not quite sure putting these files in App_Code would not cause trouble when the 'AppData' switch is used for models builder (as you would end up with two copies of the generated code?) on your running cloud environment.

    For now, using Bin mode gets me intellisense but I cannot find if UaaS would allow me to leave it on when running it 'Live': ie. can you use your cloud instances with anything other than 'PureLive' mode?

    Other than that, if you want to tweak generated models, API mode is perhaps indeed the best way to go about it.

    In any case, one of the reasons for me posting this is that it might not be immediately apparent for (inexperienced) users of UaaS who might even get confused by watching the included Umbraco.tv videos where it is mentioned that 'AppData' mode gives you intellisense and the ability to tweak models. That is however assuming your project is added to VS as a real csproj project and not as a website ...

    Perhaps it is time for some PR's to UmbracoDocs :)

  • Søren Kottal 410 posts 2504 karma points MVP c-trib
    Jun 22, 2017 @ 06:40
    Søren Kottal
    1

    Hi Kris

    I use Dll (and LiveDll) mode, and I can tweak the models. I just have to put my tweaks in App_Data/Models to get them working.

    Working with Dll mode, I can reference the generated dll in other libraries and use the model there.

    Generally I use LiveDll on dev, staging and live environments, because I want ModelsBuilder to just generate models whenever things change there.

    If I have to do a lot of changes locally, I switch to Dll mode, so the site doesn't restart on each change.

Please Sign in or register to post replies

Write your reply to:

Draft