Just starting to play with Umbraco 8 and I am getting errors in the generated models for Umbraco 8
Error:
'File' does not contain a definition for 'Value' and no extension method 'Value' accepting a first argument of type 'File' could be found (are you missing a using directive or an assembly reference?)
This error occurs for all models generated that use the syntax this.Value
e.g.
///<summary>
// Width: in pixels
///</summary
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Umbraco.ModelsBuilder", "8.0.1")]
[ImplementPropertyType("umbracoWidth")]
public int UmbracoWidth => this.Value<int>("umbracoWidth");
I notice in Umbraco 7 the same portion of model code is
///<summary>
/// Width
///</summary>
[ImplementPropertyType("umbracoWidth")]
public string UmbracoWidth
{
get { return this.GetPropertyValue<string>("umbracoWidth"); }
}
The models builder configuration in the web.config is:
We follow the same pattern successfully for all our Umbraco 7 sites - we use a 3 project solution
Umbraco.Web.PublishedContentModels - with references to Umbraco.Core and Umbraco.ModelsBuilder and System.Web
xyz.Core - with reference to project Umbraco.Web.PublishedContentModels
xyz.Web - with reference to project Umbraco.Web.PublishedContentModels
Out of the box the only model that does not throw an error and allows compilation is the default folder model - as this contains no properties to return.
He drilled into it further and found that calls to Model.Value<xyz>("abc") are also not working in the views. Yet the intellisense is there. Strangely he also noted that although Model.Value("abc"), that is iPublishedContent , appears to work but yet is not in intellisense.
I resolved this issue in my new v8 (!) project by ensuring the projects Target Framework was v4.7.2
I realized the discrepancy between intellisense in the project and the actual runtime behaviour and so checked what the umbraco v8 dlls are compiled against and that is, indeed, v4.7.2
I think for anyone generating models in their Web project it wouldn't be an issue but I guess you are, like me, generating them in a separate class project so not all UmbracoCms package dependencies are present.
Models Builder Issue in Umbraco 8
Just starting to play with Umbraco 8 and I am getting errors in the generated models for Umbraco 8
Error:
This error occurs for all models generated that use the syntax this.Value
e.g.
I notice in Umbraco 7 the same portion of model code is
The models builder configuration in the web.config is:
We follow the same pattern successfully for all our Umbraco 7 sites - we use a 3 project solution
Umbraco.Web.PublishedContentModels - with references to Umbraco.Core and Umbraco.ModelsBuilder and System.Web
xyz.Core - with reference to project Umbraco.Web.PublishedContentModels
xyz.Web - with reference to project Umbraco.Web.PublishedContentModels
Out of the box the only model that does not throw an error and allows compilation is the default folder model - as this contains no properties to return.
Any ideas anyone?
im having this issue too
My colleague is also having this issue too.
He drilled into it further and found that calls to
Model.Value<xyz>("abc")
are also not working in the views. Yet the intellisense is there. Strangely he also noted that althoughModel.Value("abc")
, that is iPublishedContent , appears to work but yet is not in intellisense.May raise on issue tracker.
A colleague at my company suggested it was something odd happening with the nuget packages and he had to install them in a specific order:
The core package
Then the models builder packages
I think you also need to watch out for missing references to System.Web
Hi I tried that but no luck.
I have raised an issue here: https://github.com/umbraco/Umbraco-CMS/issues/4780
I resolved this issue in my new v8 (!) project by ensuring the projects Target Framework was v4.7.2
I realized the discrepancy between intellisense in the project and the actual runtime behaviour and so checked what the umbraco v8 dlls are compiled against and that is, indeed, v4.7.2
hope this helps!
I resolved this by ensuring i installed the Umbraco.Web nuget package in my project where the generated models exist
Correct - thanks for posting this!
I think for anyone generating models in their Web project it wouldn't be an issue but I guess you are, like me, generating them in a separate class project so not all UmbracoCms package dependencies are present.
Spot on! This solved it for me too.
This works as expected. The value method exists in PublishedContentExtensions under Umbraco.Web assembly.
is working on a reply...