Quick update: the Enable key is required to enable models at all; the EnableApi key is not required (it is for the API for Visual Studio which I don't think you need at the moment); the ModelsMode indicates how models are generated.
With the LiveAppData models should be generated automatically in ~/App_Data/Models anytime you edit content types, however this "automatic" generation can fail, and because it all happens in the background, you will not see any error in the backend UI.
Any chance you can look at Umbraco's log for some errors that would read:
2016-02-17 10:59:39,314 [P6548/D14/T862] ERROR Umbraco.ModelsBuilder.Umbraco.LiveModelsProvider - Failed to generate models.
it will add the generated.cs files to your App_Data/Models folder which you can either include in your project or physically move them to your models folder.
Someone else might have a better method, but seems to have worked for me so far.
FWIW the "API" message is normal and if you don't know what it is... you don't need the API ;-) There's only 1 package that you need and it is the Umbraco.ModelsBuilder package.
FYI Umbraco.ModelsBuilder.EnableDllModels is deprecated (not working anymore) and the "EnableXxx" are replaced by ModelsMode eg Umbraco.modelsBuilder.ModelsMode, value="Dll".
I had upgraded on an old dummy install which had a document type called "Grid" with a property named "Grid" obviously CSharp won't allow that naming in a class and so the model builder was throwing an error.
Found it in the error log, however the Model builder dashboard was failing silently without even a JS console error.
Thanks for your help, one to watch out for just in case I suppose!
Just wondering if a lot of these issues would be resolved if the model builder suffixed "Model" or "ViewModel" to the classes?
It's a convention I would normally use anyway in a MVC environment.
Their could also be a blacklist of property names which the model builder would check against like"Properties" and anything inherited from IPublishedContent which get suffixed with "Property".
As a developer it all makes sense why we have these issues but a front ender / novice may struggle with errors like the ones we are seeing here.
I agree with what you are saying. Unfortunately, after spending two days trying to get this to work I had to give up. I was really looking forward to this feature but in my opinion it still needs a bit more refinement before it is ready for prime time.
I hear what you're saying, I think when we have instructions it shoukd make sense. It's worth it once you have it working though I can say that.
With folders for doc types to keep compositions out if the way and the way compositions are setup as interfaces you can really setup a DRY structure to views and partial views!
Indeed, because IPublishedContent already has a property named Content. Wondering if we should detect these collisions and suffix the properties with "something" to avoid the collision, eg generate ContentProperty instead of Content as proposed elsewhere in this thread.
When Models Builder was not "automatic" & embedded in Umbraco, ppl would learn about these situations & take care of them. I can understand that it is confusing now that it is supposed to "just work".
Indeed. Because IPublishedContent has a property named Properties and then there's a collision. Unfortunately these collisions are due to C# so the only solution is to make sure they do not happen.
There are ways (that I need to document) to tell the Models Builder to generate the model with a different class name eg PropertiesModel in order to get rid of the collision.
I am also wondering (see other posts in this thread) whether we should automatically detect them and add a suffix, eg PropertiesModel. But wouldn't that be confusing? How would you know that content type Foo is generated as "Foo" but Index is generated as "IndexModel"?
Having spent some considerable time searching, I cannot find a single piece of complete documentation on the appSettings for Models Builder. All I find are disperate bits of advice (like on this page) on what to set certain the values keys to. Where is all this information documented???
So, further to the original comment in this thread, is there ANYWHERE where a complete novice to ModelsBuilder can find comprehensive documentation on how to configure and use ModelsBuilder PLEASE!!!
Also, there was no note on the 7.4 upgrade page saying that if manually upgrading, to copy the ModelsBuilder folder from the AppPlugins folder in the upgrade package into an existing site (although this was obvious it should have been mentioned).
"The following weeks will see many blog posts about all the awesome new features in Umbraco 7.4"
This will hopefully include one or more post on how to use the models builder...
If I understood correctly, it's just ZBU.ModelsBuilder that has been included in the core and renamed to Umbraco.ModelsBuilder. If that's the case, you might be able to use some of the documentation here
I am trying to use ModelsBuilder on a 7.4.0 site upgraded from 7.3.7. It's enabled and mode set to AppData in the web.config, when i try and "Generate Models" from the developer section, nothing is created and no error logged in umbraco logs.
When I click on the "save and generate model" on the doc type, i get a blue notification saying it may take a while, then immediately fails, again nothing specific to models logged in the log file.
I tried on a fresh 7.4.0 site and seems to work ok, any idea what might be the issue on my upgraded site?
Can you confirm that you see no error in the log? Can you try with log4net priority set to "Debug" and see whether it makes a difference? Finally, can you enable "dev tools" in the browser (eg F12 in Chrome) and look at the response for the network request that fires when you click on "generate" in the devs section?
Ah thanks, found the issue, whilst I checked that none of my doc types had property names the same as the doc type name, I failed to realise there was a doc type called Image (i.e. the same as the Image media type), I didn't even think to check the network tab......time for a lie down!!
I had to look at the Model builder and got a few errors, which I overcome by reading this blog post, but now I get the following error in the TraceLog.txt.
This happens when I try to Save and generate models on the document type.
2016-02-20 20:03:38,335 [P4888/D2/T16] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-20 20:03:44,700 [P4888/D2/T16] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-20 20:03:44,726 [P4888/D2/T30] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-20 20:03:54,921 [P4888/D2/T40] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-20 20:03:54,954 [P4888/D2/T46] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-20 20:03:56,019 [P4888/D2/T9] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-20 20:03:56,054 [P4888/D2/T40] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
Any ideas on this one? I've resolved property fields with alias Image, Content.
The Models Builder tab doesn't do anything in the Developer section. If I click Generate models there are no console errors or errors logged in the log file.
Can you tell me how you're including App_Data\Models in your project? I have an Umbraco site and then 3 separate class libraries, Services, Controllers, Models. In VS I've set my Umbraco Site to be dependent on those other projects as they need to be built and included for my Umbraco site to work. So if I were to try and "include" something from my Umbraco site how would I do that without creating a circular reference issue?
Do you possibly mean that you just "include" the code in the same Umbraco site project as it's excluded/hidden by default?
I might be missing something simple, but I've never included just a folder from another project before, I always include the project/dll as a reference.
It may be better for you to use "DLL" models mode and then reference the generated library in all the projects that need it. That will get around your circular dependency.
That probably is the easiest solution if you are a VS dev and want to compile the models as part of your solution but don't want to deal with the VS extension.
If you'd rather have the models in a class library, then maybe it's worth trying to use the Visual Studio extension that will enable you to generate the models straight into your class library.
This is how I use the Models Builder BTW.
You can find details on how to use the VS extension in the documentation wiki on the project's GitHub.
I've actually been using the VS Extension for my current class library and it works. However it was last update Sept 2015 and when I added to my solution it's using the v2 Zbu.ModelsBuilder dlls. Is there an easy way to update it so that it uses the new v2 ModelsBuilder? Nothing seems broken at the moment using v2 but I would prefer to use the version that's shipping with current version of Umbraco.
EDIT: I just thought I'd take another look online at VS Extensions Gallery and noticed that on Feb 16 a new version of the Extension was published. That solves issue for me :) Thanks again!
There maybe some confusion due to how people "open" their Umbraco site into Visual Studio.
If you open it in VS as a "website" then:
Use ModelsMode: Dll, or LiveDll (prefereably "LiveDll") as this will auto restart the app, and redploy the Dll when you make any changes to the DocumentType in the Backoffice. You don't want to use the "AppData" mode, as this would NOT get compiled at runtime.
Dll mode will plonk a "dll" (hey!) into your bin folder automatically, and when you create a new View, you should be able to do this in VS:
If you open your site as a "Web Application", then you can Use the "AppData" or "LiveAppdata" mode, and just include the auto generated files in "AppData/Models" into your project solution. (You do this by clicking right mouse button on the file, and selecting "include in project)
I've tried everything is suggested on this topic, however I can't get Models Builder to work on my existing project.
These are the errors I was getting:
2016-02-20 20:03:54,921 [P4888/D2/T40] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-20 20:03:54,954 [P4888/D2/T46] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-20 20:03:56,019 [P4888/D2/T9] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-20 20:03:56,054 [P4888/D2/T40] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-21 13:35:44,524 [P14292/D2/T31] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field onlyImages
2016-02-21 13:35:44,524 [P14292/D2/T31] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-21 13:36:21,628 [P14292/D2/T9] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-21 13:36:29,511 [P14292/D2/T7] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field onlyImages
2016-02-21 13:36:29,511 [P14292/D2/T7] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field startNodeId
2016-02-21 13:36:40,479 [P14292/D2/T9] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field editor
2016-02-21 13:36:40,479 [P14292/D2/T9] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field hideLabel
2016-02-21 13:39:14,516 [P14292/D2/T48] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field min
2016-02-21 13:39:14,516 [P14292/D2/T48] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field step
2016-02-21 13:39:14,516 [P14292/D2/T48] WARN Umbraco.Web.Models.Mapping.PreValueDisplayResolver - Could not find persisted pre-value for field max
I've got rid of them by going to Data types as add these values for Multiple Image Picker, Rich Text Editor, Numeric, however now I have no errors in the trace log file, but when I try to Save and Generate Models I get an error suggesting to look at U logs.
Managed to get Models Builder to work on a fresh install with a starter kit from Umbraco installation.
With regards to the naming of generated content models, may I suggest to suffix the generated models with "...ContentModel".
For a while using the ModelsBuilder is my prefered way of working on Umbraco websites. When developing more complex solutions that also include "regular" MVC models (that interact with views and controllers), I often found myself having to rename my models appropriatley. After a while I started to move content models in a separate namespace and used the naming convention suffixed with "...ContentModel". This made my code not interfere with regular MVC models, or models that I use to map my Archetype's on. And it made my code easier to understand: ContentModels are a special kind that inherit from PublishedContentModel.
Currently, this requires a RenameContentType but I'm happy to use that. Even better would be a configurable option (on the custom tool, or in the application's configuration), just as the namespace is configurable, that enables you to specify your suffix of choice.
My models folder/namespace best practise:
Models - contains all regular MVC XyzModels (e.g. ContactModel)
Models\ArchetypeModels - contains all mapped XyzArchetypeModels (e.g. ContactArchetypeModel)
Models\ContentModels - contains the ContentModelBuilder class and all XyzContentModels, and their partial extensions (e.g. ContactContentModel.generated and ContactContentModel partial class extensions)
The ContentModelBuilder class contains the assembly tags for renaming or ignoring my content types:
There is an error indicated on the .HomePage so attempted to generate models in the dev section......
The Dev section says:-
ModelsBuilder is enabled, with the following configuration:
The models factory is enabled.
The API is installed and enabled.
The API endpoint is open on this server.
LiveDll models are enabled.
Models namespace is Umbraco.Web.PublishedContentModels.
Static mixin getters are enabled. The pattern for getters is "Get{0}".
Tracking of out-of-date models is not enabled.
Generating models will restart the application.
When generated, I get the following errors:-
Last generation failed with the following error:
Failed to build models.
'IPublishedContent' does not contain a definition for 'GetBodyText' and no extension method 'GetBodyText' accepting a first argument of type 'IPublishedContent' could be found (are you missing a using directive or an assembly reference?)
at Umbraco.ModelsBuilder.Building.Compiler.ThrowExceptionFromDiagnostic(IDictionary`2 files, Diagnostic diagnostic) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Building\Compiler.cs:line 154
at Umbraco.ModelsBuilder.Building.Compiler.Compile(String assemblyName, IDictionary`2 files, Stream stream) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Building\Compiler.cs:line 131
at Umbraco.ModelsBuilder.Building.Compiler.Compile(String assemblyName, IDictionary`2 files, String binPath) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Building\Compiler.cs:line 79
at Umbraco.ModelsBuilder.Umbraco.ModelsBuilderBackOfficeController.GenerateModels(String appData, String bin) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Umbraco\ModelsBuilderBackOfficeController.cs:line 126
at Umbraco.ModelsBuilder.Umbraco.ModelsBuilderBackOfficeController.BuildModels() in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Umbraco\ModelsBuilderBackOfficeController.cs:line 37
I've tried the above with ModelsMode value = "Dll" as well, it makes no difference.
I should point out the pages use docType compositions, if it makes a difference.
If you are using the Visual Studio extension and generating and compiling models in Visual Studio then you should set ModelsMode to Nothing as you do not want the site to generate models (it's done in Visual Studio).
In other words: either you generate models in Visual Studio and include them in your solution, or you generate them in the site in the Dev section, but not both.
Then, the "Failed to build models" error says that it cannot compiles the models that have been generated. Can you list the files in ~/App_Data/Models? Are you implementing partial model classes? Can you copy the content of models.generated.cs here?
What I am confused about is how to know if the extension is running or not. I assume it is not because the only way so far I've been able to get the models to generate in the ~/App_Data/Models/ folder like I want so I can include them in my project manually is to set the Mode to AppData and use the Umbraco Back office to generate the models.
I am more than happy to help update the wiki or documentation to include the steps required to setup the generation piece to be manual and only from the local environment.
I just deleted contents of AppData/Models, set ModelsMode="Nothing", rebuilt, no models built, restarted site in Umbraco, no models built. So set ModelsMode="LiveDll" again and regenerated Models from the Dev section. As previously the AppData/Models directory was populated again with:-
Admin.generated.cs
BasePage.generated.cs
Content.generated.cs
File.generated.cs
Folder.generated.cs
HomePage.generated.cs
Image.generated.cs
Member.generated.cs
models.err
SEO.generated.cs
Settings.generated.cs
Content of models.err:-
Failed to build models.
'IPublishedContent' does not contain a definition for 'GetBodyText' and no extension method 'GetBodyText' accepting a first argument of type 'IPublishedContent' could be found (are you missing a using directive or an assembly reference?)
at Umbraco.ModelsBuilder.Building.Compiler.ThrowExceptionFromDiagnostic(IDictionary`2 files, Diagnostic diagnostic) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Building\Compiler.cs:line 154
at Umbraco.ModelsBuilder.Building.Compiler.Compile(String assemblyName, IDictionary`2 files, Stream stream) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Building\Compiler.cs:line 131
at Umbraco.ModelsBuilder.Building.Compiler.Compile(String assemblyName, IDictionary`2 files, String binPath) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Building\Compiler.cs:line 79
at Umbraco.ModelsBuilder.Umbraco.ModelsBuilderBackOfficeController.GenerateModels(String appData, String bin) in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Umbraco\ModelsBuilderBackOfficeController.cs:line 126
at Umbraco.ModelsBuilder.Umbraco.ModelsBuilderBackOfficeController.BuildModels() in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Umbraco\ModelsBuilderBackOfficeController.cs:line 35
I don't understand why it's complaining about GetBodyText. It's certainly nothing I've added to a docType, unless it's something to do with the ModelsBuilder code?
Apart from being extraordinarily difficult to set up to work with in VS, it seems an odd decision for Umbraco to make whereby on a vanilla install, if you generate a docType, you are forced to use the Models Builder unless you remove the auto-generated "inherit" and "using" and replace them with
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
The result is I have a BasePage.cshtml which has no dataTypes in it's docType and has no Model generated for it, so I'm not surprised it throws an error when using the auto-generated template in VS.
I only want to use ModelsBuilder because:
1) It's the way Umbraco builds templates and
2) I understand it's supposed to be easier and simpler to type in CurrentPage.somename.
But if it takes several days to set up then it's a false economy. I'd rather just replace the "inherit" and "using" and get on with it as normal. Just puzzled as to why it's the default set up in Umbraco now when it doesn't appear it can be used in VS simply.
Well, point is, in most cases it "just works" ;-) Really sorry you are encountering these issues. I'm not sure I understand where the GetBodyText issue comes from, either, but willing to help. Could you zip the content of ~/App_Data/Models and email it to me, stephane at umbraco dot com?
Replied by email. Interesting situation. Here is what happens:
You have a content type named "Content". Which generates a class named "Content".
It is also used in a composition, for content type "HomePage".
That is, HomePage inherits property BodyText from Content.
This is implementing by getting the value from a static getter on the Content class:
///<summary>
/// Body Text: Main page content
///</summary>
[ImplementPropertyType("bodyText")]
public Newtonsoft.Json.Linq.JToken BodyText
{
get { return Content.GetBodyText(this); }
}
However, for some reason, Content is also a property of models, and it represents the inner IPublishedContent (the one you would get if you had no models). Here, the compiler fails to pick between your own Content class (which has a GetBodyText static method), and the Content property (which does not, obviously) so it fails to compile models.
Workarounds:
change the alias of the "Content" content type to eg "MyContent" - will work, but you might not want to do this, OR...
keep the alias but change the class name, so although the alias would remain "content", the model would be of type "MyContent". This can be done by creating a MyContent.cs file in ~/App_Data/Models, containing the following code:
using Umbraco.ModelsBuilder;
[assembly: RenameContentType("content", "MyContent")]
And rebuilding the models. You'll notice the Content.generated.cs files is deleted and replaced by a MyContent.generated.cs file.
The long-term fix would be for the Models Builder to detect that situation and fully qualify the "Content" class name, eg
get { return Umbraco.Web.PublishedContentModels.Content.GetBodyText(this); }
Will probably do it in the next release, but cannot do it immediately.
Alternatively, we should publish a list of "names to avoid" (eg "Content", "Index"...).
Please correct me if I'm wrong, but having got it working I'm finding it's of limited use. Most of my views are links to load partials where the main functions of the site are done. As far as I can see, the ModelsBuilder only applies to the view and as partials can't know what view they'll be called in, means you can't use it's syntax. I'm currently switching it off in all new sites.
However, I'm all ears if there's another way (that doesn't involve jumping through too many hoops ;) ).
I'm with Carl on that one: if your Partial can be used in different views for different content types, say Content1 and Content2... then those content types probably have "something in common" that is rendered in the partial.
Move that "something" to a new content type, say SomethingInCommon, and have Content1 and Content2 be composed of that new content type.
The ModelsBuilder will generate an interface for the composition, ISomethingInCommon, that you can use in the Partial. Ie, the model type of View1 is Content1, the model type of View2 is Content2, and the model type of the partial is ISomethingInCommon.
Wow, what a mess this feature is... Thought I'd be producing a quick Umbraco site this afternoon but wound up going down the Models Builder rabbit hole! Really stupid decision to enable this by default with such poor documentation.
Ah... there's been looong discussions about this. It's a tricky tool that should make it simpler for most yet can can make it more complex for others. But the experience should definitively not be that painful.
And in theory having the Models Builder enabled by default should not prevent you from doing "a quick site" the way you used to. That is, you should be able to ignore it entirely.
Do you think you could waste a little bit more time on it and list the top three pain points that you encountered? Actual points that is, ie not "missing documentation" but "I could not figure out how to do X" and "I wasted time understanding Y"? That would be very helpful.
My issue with it is that it's enabled by default and the documentation is difficult to find. I had to mess with it a good two hours to figure it out. Ultimately my problem was that I had a docType composition named "Content" and that broke things apparently. However, renaming the docType did not solve the issue; I actually had to delete all of my document types and start from scratch. So, in addition to not expecting the Models Builder to be enabled by default, having to figure out how to configure it (and still have not figure out what the Visual Studio extension is or where I obtain it), I had this extra little bug in there that just made it very frustrating.
Personally, I LOVE the idea of the Model Builder and will definitely use it, I just wish the Umbraco install itself had offered the option to enable it explicitly and perhaps some information about how to use it.
Its a level of abstraction that is standard in MVC .net.
The use of a ViewModel is a preferred approach to MVC, the model builder gives us the ability to add View models to a dynamic system which is a very useful feature.
It also adds an additional layer of error checking to Views. You cant accidentally access a property by the wrong name or type it incorrectly, which is something which can easily sneak into production environments.
In my opinion it should be the standard way of developing Umbraco sites going forward.
Have to agree with Carl on this one. Seems to me that the real problem here is that Umbraco is used by both senior programmers and hobby programmers (and everything in between). Senior programmers will love this level of abstraction, and like Carl points out, accessing properties by names(strings) will never feel right. For a hobby programmer this concept can be hard to grasp.
As a professional (not necessarily "senior" ;) ) web dev all I can say is .NET MVC has only been around a few years and not everyone is fully immersed in it outside of developing Umbraco sites.
I would agree that professional coders will like the Models Builder. It makes a lot of sense. I'm just hoping it is SOLID and doesn't come back to bite me in the future. For hobbyists (who the heck builds websites for a hobby?!), it would probably be frustrating and not necessary.
Umbraco does return a model to the view, that's strongly typed :)
Model.Content.Name etc
It's just that the 'properties' that you require are accessed through a method accessed via the model which accepts a variable (property), which is used to obtain the actual data.
It's obvious that if you create a property called 'content' it's going to clash with the standard model.content :)
I'm using Umbraco 7.4.3 and had been randomly getting YSOD saying
Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
The stack trace shows the following error not sure why.
Stack Trace:
[FileLoadException: Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
Umbraco.ModelsBuilder.Umbraco.LiveModelsProvider.get_IsEnabled() in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Umbraco\LiveModelsProvider.cs:27
Umbraco.ModelsBuilder.Umbraco.LiveModelsProviderModule.Install() in C:\Users\Stéphane\Documents\Development\Umbraco\Zbu\Zbu.ModelsBuilder\Umbraco.ModelsBuilder\Umbraco\LiveModelsProvider.cs:134
[InvalidOperationException: The pre-application start initialization method Install on type Umbraco.ModelsBuilder.Umbraco.LiveModelsProviderModule threw an exception with the following error message: Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +874
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +169
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +133
System.Web.Compilation.BuildManager.ExecutePreAppStart() +176
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +734
[HttpException (0x80004005): The pre-application start initialization method Install on type Umbraco.ModelsBuilder.Umbraco.LiveModelsProviderModule threw an exception with the following error message: Could not load file or assembly 'Microsoft.CodeAnalysis.CSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +716
Anyone got any idea? Can't figure out what triggered the error. It happens randomly.
I've done a search around and someone mentioned to delete the package folder of Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0 and then restore the nuget package. That fixes the problem.
But from time to time it happens again which is not that great.
I've an Umbraco v7.2 project that's based on the Hybrid Framework for Umbraco v7 and that introduced me to the great thing that is the ModelsBuilder.
So I've been using Zbu.ModelsBuilder v2.1.5 in Visual Studio mode for a while, before it was introduced the Umbraco core and I'd now like to upgrade my project to Umbraco v7.5 using nuGet.
My question is what do I need to do/know in order to prevent any conflicts between the existing Zbu.ModelsBuilder package that is installed in my project and the version that will come with core?
I'm thinking that if it's in the core now I'd like to use that rather than any unnecessary add-ons.
7.4 Models builder
I've just installed Umbraco 7.4 and wanted to get started with the Models builder.
I can't see any documentation on using or enabling, but on install I had issues with it not being enabled (missing web config key).
I added in the "enabled" key and "EnableApi" key but now get the following message.
Any help appreciated! Thanks
ok I've added the following to my web config and can new "generate models"
However it doesn't seem to do anythinig. no files are added to the Models folder.
Do you need I need to install any other packages to make this work?
Thanks
Carl
Quick update: the
Enable
key is required to enable models at all; theEnableApi
key is not required (it is for the API for Visual Studio which I don't think you need at the moment); theModelsMode
indicates how models are generated.With the
LiveAppData
models should be generated automatically in~/App_Data/Models
anytime you edit content types, however this "automatic" generation can fail, and because it all happens in the background, you will not see any error in the backend UI.Any chance you can look at Umbraco's log for some errors that would read:
?
Stephan
Hi Carl, I've just started trying it out myself and have had some success. If you update Umbraco.ModelsBuilder.ModelsMode to:
it will add the generated.cs files to your App_Data/Models folder which you can either include in your project or physically move them to your models folder.
Someone else might have a better method, but seems to have worked for me so far.
Hi David.
I've tried that setting too but still don't get any models generated.
Did you install any other nuget packages?
Does your dashboard still state "The API is enabled but not installed." ?
Thanks
Carl
FWIW the "API" message is normal and if you don't know what it is... you don't need the API ;-) There's only 1 package that you need and it is the Umbraco.ModelsBuilder package.
Hello,
Maybe this posts helps: http://www.zpqrtbnk.net/posts/strongly-typed-models-news
I don't think PureLive can be found anywhere. They just exist.
You could also add this to the web.config:
Than the models will be generated in Umbraco.Web.PublishedContentModels.dll in the bin folder.
Jeroen
FYI Umbraco.ModelsBuilder.EnableDllModels is deprecated (not working anymore) and the "EnableXxx" are replaced by ModelsMode eg Umbraco.modelsBuilder.ModelsMode, value="Dll".
I know.
Currently writing doc.
Thanks Jeroen, Pure live models looks interesting.
Carl, No havent installed anything but a fresh 7.4 through nuget and added the 3 keys to my web.config.
Yes, my dashboard states The API is enabled but not installed.
When I click the Generate models button, it adds the classes under ~/app_Data/Models/[doctypename].generated.cs
Hope that helps
Found it.
I had upgraded on an old dummy install which had a document type called "Grid" with a property named "Grid" obviously CSharp won't allow that naming in a class and so the model builder was throwing an error.
Found it in the error log, however the Model builder dashboard was failing silently without even a JS console error.
Thanks for your help, one to watch out for just in case I suppose!
Thanks
Carl
I also discovered that you cannot have document type named Properties. This will cause conflicts in the models and they will not compile.
Just wondering if a lot of these issues would be resolved if the model builder suffixed "Model" or "ViewModel" to the classes?
It's a convention I would normally use anyway in a MVC environment.
Their could also be a blacklist of property names which the model builder would check against like"Properties" and anything inherited from IPublishedContent which get suffixed with "Property".
As a developer it all makes sense why we have these issues but a front ender / novice may struggle with errors like the ones we are seeing here.
Thanks
I agree with what you are saying. Unfortunately, after spending two days trying to get this to work I had to give up. I was really looking forward to this feature but in my opinion it still needs a bit more refinement before it is ready for prime time.
I hear what you're saying, I think when we have instructions it shoukd make sense. It's worth it once you have it working though I can say that.
With folders for doc types to keep compositions out if the way and the way compositions are setup as interfaces you can really setup a DRY structure to views and partial views!
It doesn't work if you have a document type named Content either.
Indeed, because IPublishedContent already has a property named Content. Wondering if we should detect these collisions and suffix the properties with "something" to avoid the collision, eg generate
ContentProperty
instead ofContent
as proposed elsewhere in this thread.When Models Builder was not "automatic" & embedded in Umbraco, ppl would learn about these situations & take care of them. I can understand that it is confusing now that it is supposed to "just work".
Indeed. Because IPublishedContent has a property named Properties and then there's a collision. Unfortunately these collisions are due to C# so the only solution is to make sure they do not happen.
There are ways (that I need to document) to tell the Models Builder to generate the model with a different class name eg PropertiesModel in order to get rid of the collision.
I am also wondering (see other posts in this thread) whether we should automatically detect them and add a suffix, eg PropertiesModel. But wouldn't that be confusing? How would you know that content type Foo is generated as "Foo" but Index is generated as "IndexModel"?
I would say we suffix "Model" to the class on every model. (adding a setting for backward compatibility)
It would be just conflicting properties that would be detected and suffixed?
Using intelisense its easy to see.... but understand taht isn't how everyone works.
Having spent some considerable time searching, I cannot find a single piece of complete documentation on the appSettings for Models Builder. All I find are disperate bits of advice (like on this page) on what to set certain the values keys to. Where is all this information documented???
So, further to the original comment in this thread, is there ANYWHERE where a complete novice to ModelsBuilder can find comprehensive documentation on how to configure and use ModelsBuilder PLEASE!!!
Also, there was no note on the 7.4 upgrade page saying that if manually upgrading, to copy the ModelsBuilder folder from the AppPlugins folder in the upgrade package into an existing site (although this was obvious it should have been mentioned).
I am currently putting together such a doc, to be released sometime this week. I know. I'm sorry.
Stephan
Thanks Stephan,
Really appreciate all the hard work you've put into Models Builder!
From the 7.4 blog post:
"The following weeks will see many blog posts about all the awesome new features in Umbraco 7.4"
This will hopefully include one or more post on how to use the models builder...
If I understood correctly, it's just ZBU.ModelsBuilder that has been included in the core and renamed to Umbraco.ModelsBuilder. If that's the case, you might be able to use some of the documentation here
It is, unfortunately the doc is not up-to-date at the moment - in a few days.
I am trying to use ModelsBuilder on a 7.4.0 site upgraded from 7.3.7. It's enabled and mode set to AppData in the web.config, when i try and "Generate Models" from the developer section, nothing is created and no error logged in umbraco logs.
When I click on the "save and generate model" on the doc type, i get a blue notification saying it may take a while, then immediately fails, again nothing specific to models logged in the log file.
I tried on a fresh 7.4.0 site and seems to work ok, any idea what might be the issue on my upgraded site?
Can you confirm that you see no error in the log? Can you try with log4net priority set to "Debug" and see whether it makes a difference? Finally, can you enable "dev tools" in the browser (eg F12 in Chrome) and look at the response for the network request that fires when you click on "generate" in the devs section?
Thanks
Ah thanks, found the issue, whilst I checked that none of my doc types had property names the same as the doc type name, I failed to realise there was a doc type called Image (i.e. the same as the Image media type), I didn't even think to check the network tab......time for a lie down!!
Mmm... but there was no error in the log? Can you confirm? Then, that's bad and we need to fix!
This is the same as the issue I had, I did get a log error but I use Usync and it was getting pushed up the log by the usync event logs.
As per Chris above though, there is no error message in the backend when generating models from the dashboard screen.
I got it working :)
This page might help on the valid "ModelsMode"
https://github.com/zpqrtbnk/Zbu.ModelsBuilder/blob/master/Umbraco.ModelsBuilder/Configuration/ModelsMode.cs
Documentation is currently work-in-progress but you may find the following page interesting https://github.com/zpqrtbnk/Zbu.ModelsBuilder/wiki/Builder-Modes
Hi,
I had to look at the Model builder and got a few errors, which I overcome by reading this blog post, but now I get the following error in the TraceLog.txt.
This happens when I try to Save and generate models on the document type.
Any ideas on this one? I've resolved property fields with alias Image, Content.
The Models Builder tab doesn't do anything in the Developer section. If I click Generate models there are no console errors or errors logged in the log file.
Thanks,
Paulius
For VS devs, simply:
In your view inherit from UmbracoViewPage < GeneratedModel >
Access strong typed members on Model.SomeProp
Oila!
Hi Kenneth,
Can you tell me how you're including App_Data\Models in your project? I have an Umbraco site and then 3 separate class libraries, Services, Controllers, Models. In VS I've set my Umbraco Site to be dependent on those other projects as they need to be built and included for my Umbraco site to work. So if I were to try and "include" something from my Umbraco site how would I do that without creating a circular reference issue?
Do you possibly mean that you just "include" the code in the same Umbraco site project as it's excluded/hidden by default?
I might be missing something simple, but I've never included just a folder from another project before, I always include the project/dll as a reference.
Thanks in advance. Regards,
It may be better for you to use "DLL" models mode and then reference the generated library in all the projects that need it. That will get around your circular dependency.
That probably is the easiest solution if you are a VS dev and want to compile the models as part of your solution but don't want to deal with the VS extension.
If you'd rather have the models in a class library, then maybe it's worth trying to use the Visual Studio extension that will enable you to generate the models straight into your class library.
This is how I use the Models Builder BTW.
You can find details on how to use the VS extension in the documentation wiki on the project's GitHub.
Hi Stephen,
I've actually been using the VS Extension for my current class library and it works. However it was last update Sept 2015 and when I added to my solution it's using the v2 Zbu.ModelsBuilder dlls. Is there an easy way to update it so that it uses the new v2 ModelsBuilder? Nothing seems broken at the moment using v2 but I would prefer to use the version that's shipping with current version of Umbraco.
EDIT: I just thought I'd take another look online at VS Extensions Gallery and noticed that on Feb 16 a new version of the Extension was published. That solves issue for me :) Thanks again!
https://visualstudiogallery.msdn.microsoft.com/ef0896ab-e2eb-47fc-8fcb-79dad0f66e30
Thanks, Phill
This fixed it. I didn't see the all.generated.cs file in the Models folder.
Just upgraded from 7.3.1 to latest and under the "Model Builder" Tab its empty :-(
There maybe some confusion due to how people "open" their Umbraco site into Visual Studio.
If you open it in VS as a "website" then:
Use ModelsMode: Dll, or LiveDll (prefereably "LiveDll") as this will auto restart the app, and redploy the Dll when you make any changes to the DocumentType in the Backoffice. You don't want to use the "AppData" mode, as this would NOT get compiled at runtime.
Dll mode will plonk a "dll" (hey!) into your bin folder automatically, and when you create a new View, you should be able to do this in VS:
If you open your site as a "Web Application", then you can Use the "AppData" or "LiveAppdata" mode, and just include the auto generated files in "AppData/Models" into your project solution. (You do this by clicking right mouse button on the file, and selecting "include in project)
Hope that clears things up! :D
Hi,
I've tried everything is suggested on this topic, however I can't get Models Builder to work on my existing project.
These are the errors I was getting:
I've got rid of them by going to Data types as add these values for Multiple Image Picker, Rich Text Editor, Numeric, however now I have no errors in the trace log file, but when I try to Save and Generate Models I get an error suggesting to look at U logs.
Managed to get Models Builder to work on a fresh install with a starter kit from Umbraco installation.
/ Paulius
With regards to the naming of generated content models, may I suggest to suffix the generated models with "...ContentModel".
For a while using the ModelsBuilder is my prefered way of working on Umbraco websites. When developing more complex solutions that also include "regular" MVC models (that interact with views and controllers), I often found myself having to rename my models appropriatley. After a while I started to move content models in a separate namespace and used the naming convention suffixed with "...ContentModel". This made my code not interfere with regular MVC models, or models that I use to map my Archetype's on. And it made my code easier to understand: ContentModels are a special kind that inherit from PublishedContentModel.
Currently, this requires a RenameContentType but I'm happy to use that. Even better would be a configurable option (on the custom tool, or in the application's configuration), just as the namespace is configurable, that enables you to specify your suffix of choice.
My models folder/namespace best practise:
The ContentModelBuilder class contains the assembly tags for renaming or ignoring my content types:
Umb 7.4.2, fresh install. I'm trying for a second time to get this to work.
I have the VS Extension installed, the Umbraco.ModelsBuilder.API installed, web.config :-
The top of my Home page template has:-
There is an error indicated on the .HomePage so attempted to generate models in the dev section......
The Dev section says:-
When generated, I get the following errors:-
I've tried the above with ModelsMode value = "Dll" as well, it makes no difference.
I should point out the pages use docType compositions, if it makes a difference.
Any advice would be appreciated.
Several things:
If you are using the Visual Studio extension and generating and compiling models in Visual Studio then you should set ModelsMode to Nothing as you do not want the site to generate models (it's done in Visual Studio).
In other words: either you generate models in Visual Studio and include them in your solution, or you generate them in the site in the Dev section, but not both.
Then, the "Failed to build models" error says that it cannot compiles the models that have been generated. Can you list the files in ~/App_Data/Models? Are you implementing partial model classes? Can you copy the content of models.generated.cs here?
How do you have your workflow setup for this to work, Stephen?
I installed the VS2015 extension and set the options to point to the following:
Umbraco Url: http://localhost:<-port-for-iis-express->
Along with my username and password that is to a user that is a developer.
What I am confused about is how to know if the extension is running or not. I assume it is not because the only way so far I've been able to get the models to generate in the ~/App_Data/Models/ folder like I want so I can include them in my project manually is to set the Mode to AppData and use the Umbraco Back office to generate the models.
I am more than happy to help update the wiki or documentation to include the steps required to setup the generation piece to be manual and only from the local environment.
Thanks!
See "API Models " on https://github.com/zpqrtbnk/Zbu.ModelsBuilder/wiki/Builder-Modes - basically, once the extension is installed and configured you need to create a specific folder + cs file in your solution. Let me know if the wiki/doc is not clear.
Thanks, Stephen, this clears it up for me!
I just deleted contents of AppData/Models, set ModelsMode="Nothing", rebuilt, no models built, restarted site in Umbraco, no models built. So set ModelsMode="LiveDll" again and regenerated Models from the Dev section. As previously the AppData/Models directory was populated again with:- Admin.generated.cs
BasePage.generated.cs
Content.generated.cs
File.generated.cs
Folder.generated.cs
HomePage.generated.cs
Image.generated.cs
Member.generated.cs
models.err
SEO.generated.cs
Settings.generated.cs
Content of models.err:-
I don't understand why it's complaining about GetBodyText. It's certainly nothing I've added to a docType, unless it's something to do with the ModelsBuilder code?
Apart from being extraordinarily difficult to set up to work with in VS, it seems an odd decision for Umbraco to make whereby on a vanilla install, if you generate a docType, you are forced to use the Models Builder unless you remove the auto-generated "inherit" and "using" and replace them with
The result is I have a BasePage.cshtml which has no dataTypes in it's docType and has no Model generated for it, so I'm not surprised it throws an error when using the auto-generated template in VS.
I only want to use ModelsBuilder because: 1) It's the way Umbraco builds templates and 2) I understand it's supposed to be easier and simpler to type in CurrentPage.somename.
But if it takes several days to set up then it's a false economy. I'd rather just replace the "inherit" and "using" and get on with it as normal. Just puzzled as to why it's the default set up in Umbraco now when it doesn't appear it can be used in VS simply.
Well, point is, in most cases it "just works" ;-) Really sorry you are encountering these issues. I'm not sure I understand where the GetBodyText issue comes from, either, but willing to help. Could you zip the content of ~/App_Data/Models and email it to me, stephane at umbraco dot com?
Thanks Stephen,
Sent with Subject line: "Models Builder Issue 75079-74-models-builder"
Replied by email. Interesting situation. Here is what happens:
You have a content type named "Content". Which generates a class named "Content". It is also used in a composition, for content type "HomePage".
That is, HomePage inherits property BodyText from Content. This is implementing by getting the value from a static getter on the Content class:
However, for some reason, Content is also a property of models, and it represents the inner IPublishedContent (the one you would get if you had no models). Here, the compiler fails to pick between your own Content class (which has a GetBodyText static method), and the Content property (which does not, obviously) so it fails to compile models.
Workarounds:
change the alias of the "Content" content type to eg "MyContent" - will work, but you might not want to do this, OR...
keep the alias but change the class name, so although the alias would remain "content", the model would be of type "MyContent". This can be done by creating a MyContent.cs file in ~/App_Data/Models, containing the following code:
And rebuilding the models. You'll notice the Content.generated.cs files is deleted and replaced by a MyContent.generated.cs file.
The long-term fix would be for the Models Builder to detect that situation and fully qualify the "Content" class name, eg
Will probably do it in the next release, but cannot do it immediately.
Alternatively, we should publish a list of "names to avoid" (eg "Content", "Index"...).
Please correct me if I'm wrong, but having got it working I'm finding it's of limited use. Most of my views are links to load partials where the main functions of the site are done. As far as I can see, the ModelsBuilder only applies to the view and as partials can't know what view they'll be called in, means you can't use it's syntax. I'm currently switching it off in all new sites.
However, I'm all ears if there's another way (that doesn't involve jumping through too many hoops ;) ).
Craig
I'm with Carl on that one: if your Partial can be used in different views for different content types, say Content1 and Content2... then those content types probably have "something in common" that is rendered in the partial.
Move that "something" to a new content type, say SomethingInCommon, and have Content1 and Content2 be composed of that new content type.
The ModelsBuilder will generate an interface for the composition, ISomethingInCommon, that you can use in the Partial. Ie, the model type of View1 is Content1, the model type of View2 is Content2, and the model type of the partial is ISomethingInCommon.
Making sense?
Depends how you structure your doc types, if you use compositions then models builder adds an interface for each composition
You can then type your partial with an interface and by polymorphism each doc type with that composition can call the partial.
That's interesting. I might look at that, thanks.
Wow, what a mess this feature is... Thought I'd be producing a quick Umbraco site this afternoon but wound up going down the Models Builder rabbit hole! Really stupid decision to enable this by default with such poor documentation.
Hi Robert.
I agree some official documentation is needed, but in general I don't think it's a 'mess'.
What specific issues have you had?
Carl
Ah... there's been looong discussions about this. It's a tricky tool that should make it simpler for most yet can can make it more complex for others. But the experience should definitively not be that painful.
And in theory having the Models Builder enabled by default should not prevent you from doing "a quick site" the way you used to. That is, you should be able to ignore it entirely.
Do you think you could waste a little bit more time on it and list the top three pain points that you encountered? Actual points that is, ie not "missing documentation" but "I could not figure out how to do X" and "I wasted time understanding Y"? That would be very helpful.
Thanks! Sorry about your experience.
Stephan
Also... want to comment on https://our.umbraco.org/forum/using-umbraco-and-getting-started/76992-models-builder-gripes#comment-246114 ?
My issue with it is that it's enabled by default and the documentation is difficult to find. I had to mess with it a good two hours to figure it out. Ultimately my problem was that I had a docType composition named "Content" and that broke things apparently. However, renaming the docType did not solve the issue; I actually had to delete all of my document types and start from scratch. So, in addition to not expecting the Models Builder to be enabled by default, having to figure out how to configure it (and still have not figure out what the Visual Studio extension is or where I obtain it), I had this extra little bug in there that just made it very frustrating.
Personally, I LOVE the idea of the Model Builder and will definitely use it, I just wish the Umbraco install itself had offered the option to enable it explicitly and perhaps some information about how to use it.
Turn this feature off by default. Can't really see any real world legit use for it, and only saves you a few keystrokes.
It just adds an extra layer of abstraction, and adds yet another way just to get to a bog standard property value.
@Paul, I'm inclined to agree.
Its a level of abstraction that is standard in MVC .net.
The use of a ViewModel is a preferred approach to MVC, the model builder gives us the ability to add View models to a dynamic system which is a very useful feature.
It also adds an additional layer of error checking to Views. You cant accidentally access a property by the wrong name or type it incorrectly, which is something which can easily sneak into production environments.
In my opinion it should be the standard way of developing Umbraco sites going forward.
Have to agree with Carl on this one. Seems to me that the real problem here is that Umbraco is used by both senior programmers and hobby programmers (and everything in between). Senior programmers will love this level of abstraction, and like Carl points out, accessing properties by names(strings) will never feel right. For a hobby programmer this concept can be hard to grasp.
As a professional (not necessarily "senior" ;) ) web dev all I can say is .NET MVC has only been around a few years and not everyone is fully immersed in it outside of developing Umbraco sites.
I would agree that professional coders will like the Models Builder. It makes a lot of sense. I'm just hoping it is SOLID and doesn't come back to bite me in the future. For hobbyists (who the heck builds websites for a hobby?!), it would probably be frustrating and not necessary.
Umbraco does return a model to the view, that's strongly typed :)
Model.Content.Name etc
It's just that the 'properties' that you require are accessed through a method accessed via the model which accepts a variable (property), which is used to obtain the actual data.
It's obvious that if you create a property called 'content' it's going to clash with the standard model.content :)
How do I render the grid with the strongly typed model? I can see in the model that the propery is stored as a JToken.
This just prints the JSON-object
Hi Stephen and everyone,
I'm using Umbraco 7.4.3 and had been randomly getting YSOD saying
The stack trace shows the following error not sure why.
Stack Trace:
Anyone got any idea? Can't figure out what triggered the error. It happens randomly.
I've done a search around and someone mentioned to delete the package folder of Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0 and then restore the nuget package. That fixes the problem.
But from time to time it happens again which is not that great.
Thanks
I've an Umbraco v7.2 project that's based on the Hybrid Framework for Umbraco v7 and that introduced me to the great thing that is the ModelsBuilder.
So I've been using Zbu.ModelsBuilder v2.1.5 in Visual Studio mode for a while, before it was introduced the Umbraco core and I'd now like to upgrade my project to Umbraco v7.5 using nuGet.
My question is what do I need to do/know in order to prevent any conflicts between the existing Zbu.ModelsBuilder package that is installed in my project and the version that will come with core?
I'm thinking that if it's in the core now I'd like to use that rather than any unnecessary add-ons.
Thanks, Matt
I've upgraded a website to 7.5 and it's still using the old version of the ModelsBuilder. I didn't have any conflicts yet.
However it's pretty easy to remove the old models builder and use the new version. You probably only need to update some namespaces after regenerating the models. I also did it for the 1-1 multilingual example: https://github.com/jbreuer/1-1-multilingual-example/commit/89cbd54f3d971c2e97c91125b4699beda0dcdfa5
Jeroen
Thanks Jeroen,
I've performed the upgrade and like you say the original ModelsBuilder continued to work.
I'm sure I saw some posts before about some people having trouble with it.
Now I'll figure out how remove the original version and use the new one.
Cheers, Matt
Hi Matt,
Glad to hear the upgrade went well. If you've installed the old version with NuGet you can use that to uninstall. I also did it in this commit: https://github.com/jbreuer/1-1-multilingual-example/commit/ac1399ca13c0c45fe2d12843e5646519371529e5
Jeroen
is working on a reply...