The error you are seeing is misleading I believe. I'm making an assumption that you are using a default installation of Umbraco here.
By default, Umbraco runs with models in Pure Live mode. What this means is that the class models don't really exist until runtime. The templates that are created by Umbraco have code to access the model, however because they don't quite exist yet visual studio, in particular, the intelisese and the compiler don't know about the classes. This is why "errors" are shown. The reason they are false errors is because the views aren't evaluated untill runtime and by this point the pure live models have been generated and so no error actually exists.
If you want to have intelisese pick up the models you'll need to change the models builder mode.
Visual Studio 2019 Frustrations
I am attempting to work with templates in Visual Studio 2019 after creation in the Umbraco Back Office (using Umbraco V.8.3).
Whenever I create a new document type and attempto open the associated template/view in Visual Studio, I instantly receive an error stating that the
I thought I was able to use VS, but it appears I cannot (?).
Am I missing something?
Thank you, Bill Even CTG
Might need to switch your Models Builder Mode: https://our.umbraco.com/documentation/reference/templating/modelsbuilder/
Hey Bill,
The error you are seeing is misleading I believe. I'm making an assumption that you are using a default installation of Umbraco here.
By default, Umbraco runs with models in Pure Live mode. What this means is that the class models don't really exist until runtime. The templates that are created by Umbraco have code to access the model, however because they don't quite exist yet visual studio, in particular, the intelisese and the compiler don't know about the classes. This is why "errors" are shown. The reason they are false errors is because the views aren't evaluated untill runtime and by this point the pure live models have been generated and so no error actually exists.
If you want to have intelisese pick up the models you'll need to change the models builder mode.
Nik
Amir and Nik both had the right idea, but Nik provided a little more detail. I marked you both as solution givers.
Thank you.
Bill
Thanks Bill, glad you sorted it out. Amazing how those types of things can be so frustrating the first time you encounter them.
is working on a reply...