Copied to clipboard

Flag this post as spam?

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


  • Ayo Adesina 445 posts 1059 karma points
    Jun 09, 2018 @ 00:03
    Ayo Adesina
    0

    Umbraco Model builder - In the Cloud

    Hi guys,

    I am trying to get the Umbraco Model builder to generate my models and put them in the app_code directory (I'm using Umbraco cloud) and I want to have intlisense in my views and custom code.

    These are my settings

        <add key="Umbraco.ModelsBuilder.Enable" value="true"/>
    <add key="Umbraco.ModelsBuilder.ModelsMode" value="Dll"/>
    <add key="Umbraco.ModelsBuilder.ModelsDirectory" value="~/App_Code"/>
    

    When I go in to umbraco back office and generate the models, I get all the models in my App_code folder as expected, but it also genrates a Umbraco.Web.PublishedContentModels.dll file with all the models and puts it in the bin folder.

    Why is Umbraco generating two versions of the models, how do I stop it from doing so?

  • Søren Gregersen 441 posts 1884 karma points MVP 2x c-trib
    Jun 09, 2018 @ 05:51
    Søren Gregersen
    0

    https://our.umbraco.org/Documentation/reference/templating/Modelsbuilder/Builder-Modes

    Models Builder can be used in different modes:

    PureLive models

    Dll models

    AppData models

    API models

    So per your configuration you are using Dll Models.

    With Dll models, models are generated in the ~/App_Data/Models directory, then compiled into a Dll that is copied into ~/bin, thus restarting the application. Models must be generated explicitly from the dashboard or the content type editor.

    It is doing what you have configured :)

    On umbraco cloud, C# files aren't compiled, so you need to make sure they are build before publishing. The "Dll" mode does this, but it needs the files in order to compile them - thus you get cs files+dll. If you use mode "LiveAppData", it only generates the files, but then you have to compile them yourself.

    Normally you don't need to change settings on umbraco cloud projects. What are you trying to benefit from using another setup?

  • Ayo Adesina 445 posts 1059 karma points
    Jun 09, 2018 @ 08:09
    Ayo Adesina
    0

    I went through the documentation and I have read about the different modes, and after reading about each one I wanted to use either DLL or LiveDLL mode.

    I understand that in DLL mode I need to click Generate Models and with LiveDLL the changes happen when you make a change to the document types.

    I like the generation of each document type individually and because I am using cloud I am setting the output directory to /app_code so I can get full intelisense inside my views and in custom code.

    The issue is every-time I generate the models, it works. I get a class genrated for each document type in app_code, but I also get Umbraco.Web.PublishedContentModels.dll in the bin directory resulting in:

    "More that one type want to be a model for content type" message. Then I have to delete that DLL then everything works.

    What I want to know is why is Umbraco generating the DLLs in two different ways, I only want the DLLs generated in app_code.

  • Ayo Adesina 445 posts 1059 karma points
    Jun 09, 2018 @ 11:10
    Ayo Adesina
    100

    In the end I just went with these two settings:

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

    So now there is no out put in to the app_code folder and I just have the Umbraco.Web.PublishedContentModels.dll in the bin directory.

    But it would be nice to know how to get it to work properly the other way.

Please Sign in or register to post replies

Write your reply to:

Draft