Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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:
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=22.214.171.124, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add namespace="Umbraco.Web.PublishedContentModels" />
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?)
Even so, this is what my views tell me:
Also, the application does not run locally:
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 :)
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.
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:
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 :)
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.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted