-> 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!
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
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.
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 :)
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?
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.
"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" ?
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?
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
Create Doctype with all content editable properties in the CMS
Generate models
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.
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:
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?
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.
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
Models builder does not allow you to do "Code first".
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
Thanks for helping matt
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 :)
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?
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
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
"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
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?
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
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
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!
is working on a reply...