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
Umbraco 8.6.1, Models Builder embedded
I using AppData mode for the first time after a long time of Dll mode usage.
For some reason, Intellisense doesn't recognize any models, whatever I do.
For example, here is a regular HomePage model, it was included in the project:
<Content Include="App_Data\Models\HomePage.generated.cs" />
And commonly used in the view:
@using ContentModels = Umbraco.Web.PublishedModels;
Intellisense doesn't see it and I get compilation errors :(
What may be wrong?
It looks as if your ContentModels namespace might be incorrect - when I use appdata I usually put my models in a separate "core" class library and I will usually get something like:
@using ContentModels = ProjectName.Core.Models.ClassName;
In my views - so I would check the namespace in your HomePage.generated.cs class.
I didn't change the standard namespace, it is Umbraco.Web.PublishedModels
public partial class HomePage : PublishedContentModel
Actually I think I've had something like this happen in Visual Studio myself - it sometimes gives loads of errors in the view about namespaces like "System" not being found; usually I can fix it by closing and re-opening the project.
What happens if you change the first line to
I think this can also happen if the namespace isn't specified in the web.config file in the Views directory - something like this should be in there:
<add namespace="System.Web.Mvc" />
(Can't get the editor to show the whole thing, but
<add namespace="Umbraco.Web.PublishedModels" />
Should be in the namespaces element)
Nope, didn't help :(
Checked, has it in /Views/Web.config :(
As a result of VS solution including manipulations (manually too), that node missed from project config (YourUmbracoProjectName.csproj):
<Compile Include="App_Data\Models\*.generated.cs" /> <!-- Missing it -->
<Compile Include="Properties\AssemblyInfo.cs" />
And seems it is a reason why Intellisense doesn't see it, models not compiled at all.
The reason I did manual changes in including settings, I wanted my generated models includes automatically to a solution. But it seems VS causes errors when you start to manipulate that folder with UI then.
So, here is a solution:
Just add ModelsBuilder folder settings
<add key="Umbraco.ModelsBuilder.ModelsDirectory" value="~/App_Code/Models" />
Models will be generated to App_Code/Models folder that compiles automatically. I don't sure about performance, but it solves the problem.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted