Copied to clipboard

Flag this post as spam?

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


  • Andy 13 posts 54 karma points
    Apr 03, 2020 @ 13:36
    Andy
    0

    ModelsMode "Dll" is not a valid mode

    This is getting a tad ridiculous now!

    trying to use models builder as suggested in this tutorial : https://24days.in/umbraco-cms/2016/getting-started-with-modelsbuilder/

    changing my web config to:

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

    and when i run my project I get this!

    Boot failed: Umbraco cannot run. See Umbraco's log file for more details.

    -> Umbraco.Core.Exceptions.BootFailedException: Boot failed.

    -> System.Configuration.ConfigurationErrorsException: ModelsMode "Dll" is not a valid mode. Note that modes are case-sensitive. Possible values are: Nothing, PureLive, AppData, LiveAppData at Umbraco.ModelsBuilder.Embedded.Configuration.ModelsBuilderConfig.<>c.

    just failed to build completely.

    This is very frustrating. All i want to do is generated strongly typed models from code and I can't find a single piece of info online that works!

    can someone help me out here?

  • Sebastian 5 posts 75 karma points
    Apr 03, 2020 @ 13:43
    Sebastian
    0

    Unfortunately I do not have a solution for you because I was just searching for the exactly same issue you're having.

    I will gladly follow this thread in hope that someone has an answer.

  • Andy 13 posts 54 karma points
    Apr 03, 2020 @ 13:45
    Andy
    0

    let's suffer together!

    in terms of actually using the modelsbuilder, do you know how to create docuement types from code? thats exactly what i'm trying to do here but either get dumb blockers like this or can't find clear enough instructions

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Apr 03, 2020 @ 13:49
    Matthew Wise
    0

    Models builder does not allow you to do "Code first".

  • Matthew Wise 271 posts 1373 karma points MVP 5x c-trib
    Apr 03, 2020 @ 13:48
    Matthew Wise
    1

    That blog post is using the plugin version.

    You are using the embedded version that does not support dll mode you can get the plugin version via nuGet here - https://www.nuget.org/packages/Umbraco.ModelsBuilder/

    If you dont want to use the plugin you can instead use LiveAppData and include the .cs files generated in your project to still get intellisense in Visual studio etc.

    Hope this helps

    Matt

  • Andy 13 posts 54 karma points
    Apr 03, 2020 @ 13:50
    Andy
    0

    Thanks for helping matt

  • Sebastian 5 posts 75 karma points
    Apr 03, 2020 @ 14:44
    Sebastian
    0

    I have taken the latter approach and used the LiveAppData mode and included models folder in App_Data in the solution which seemed to do the trick for me. Thanks for the help :)

  • Andy 13 posts 54 karma points
    Apr 03, 2020 @ 13:52
    Andy
    0

    Hi @Matt,

    Apologies I think I should rephrase my question, what I am trying to achieve is to use umbraco models builder and work to strongly type models. can you provide any context on how to do what?

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Apr 03, 2020 @ 13:56
    Nik
    0

    Hi Andy,

    Personally, the approach I would take is a the AppData mode with Models Builder. This generates partial class .cs files for each of your doc types. You can then include these in your project and use additional partial class files to extend the generated models if you want to.

    There is no approach for Code First (which I believe you've mentioned in a different forum post).

    This works nicely for you to be able to have strongly typed classes to represent your doc types in code.

    There are also additional settings that allow you to put these CS files in a different directory/project if you want as well as customise the namespace that they sit in, by default with is Umbraco.Web.PublishedModels I beleive.

    Does that help?

    Nik

  • Andy 13 posts 54 karma points
    Apr 03, 2020 @ 14:01
    Andy
    0

    Hi Nik thanks for replying!

    So just to confirm (and I really apologise is this is a stupid question) I come from an Episerver backgrounf so its quite a bit different)

    I am unable to create a document from code and then export to the CMS.

    instead I must create the document type in the CMS, and then I am able to further customise its properties in my code?

    Sorry if i've missed the point!

    Andy

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Apr 03, 2020 @ 14:07
    Nik
    0

    "Yep", I say that with quotes as there is a few bits to consider.

    The models created are designed for rendering purposes mainly, and if you were to modify the ModelsBuilder generated files they would get overridden when models builder next generates models. Hence the partial class approach.

    The Full Models Builder (Not the new Embeded models builder which Umbraco 8.5+ ships with) has some abilities to override some properties via the use of attributes but I've not used that functionality myself.

    I guess my next question for you would be, what do you mean by "further customise its properties" ?

    Nik

  • Andy 13 posts 54 karma points
    Apr 03, 2020 @ 14:17
    Andy
    0

    So for example in my CMS i create a doc type with a property called title of type string

    could i then add further properties like something called text area of type text area from code?

    I guess what im struggling to understand here, is what is the point of having these options if you can create everything via the cms? and vice versa?

    I come from episerver and the flow is

    create your model (doc type) with its properties it appears in the cms

    what is to be gained from creating your document type in the cms and then having to pull it in your code? like what is the use case for it? why would someone want to work on it from there code?

  • Nik 1617 posts 7263 karma points MVP 7x c-trib
    Apr 03, 2020 @ 14:23
    Nik
    0

    Okay, nope, so the idea of the Models is to help with your view rendering not to push anything back into the CMS. Consider them one directional models.

    The flow with Umbraco would therefor be

    1. Create Doctype with all content editable properties in the CMS
    2. Generate models
    3. Use models in your views/controllers when retrieving cms data from the cache

    An example of wanting to extend your CMS generated models might be:

    You have a CMS Product doc type that has a property called "SKU" and it contains a small bit of CMS editable information.

    You could extend your Product doc type to have a "ERPDetails" property that is populated from a 3rd party ERP system to contain further product details such as stock qty etc.

    You could then use RouteHijacking and a RenderMVC Controller to intercept requests to a Product Page, call your ERP System, populate this new property with results, and then pass it all through to your Product view.

    Does that make sense?

    Nik

  • Andy 13 posts 54 karma points
    Apr 03, 2020 @ 14:54
    Andy
    101

    ahhh yes absolutely!

    Thanks so much! I think I was stuck in the episerver way of thinking, seeing as thats the only CMS i've ever used!

    so i create the doc type in the CMS

    Use that generated model to implement the functionality i require and pass that to the views

    thanks!!

    Totally understood now!

Please Sign in or register to post replies

Write your reply to:

Draft