❔ The type or namespace name Model could not be found

Hi, I'm facing an error on a missing directive when trying to specify the model name in my view model. I'm not sure if this works on Models directory but it works across controllers and views, so I assume it does. So, I have all my imports called in "_ViewImports", and this includes the model directory. However, when I wanted to use the model name, I get the error. I mean, calling the import inside the view model solves the issue, but I was looking to not include it in since I already have "_ViewImports". For example,
namespace Test.Web.Area.Admin.SomeViewModel {
public class SomeViewModel {
public List<ModelName> { get; set; }
}
}
namespace Test.Web.Area.Admin.SomeViewModel {
public class SomeViewModel {
public List<ModelName> { get; set; }
}
}
Then the error appears on "ModelName"
6 Replies
Saber
Saber3y ago
I kind of doubt _ViewImports works for controllers because its mainly a razor concept
TheRanger
TheRanger3y ago
u didnt give a name to ur property
CoreVisional
CoreVisionalOP3y ago
As for my ViewImports, I already have
@using Test.EntityModels.Models
@using Test.EntityModels.Models
Okay it seems like I can't edit the post while on phone, forgot to include the name. Anyways, the error is still there even with the name
TheRanger
TheRanger3y ago
maybe you could try Global Using Directives instead
CoreVisional
CoreVisionalOP3y ago
Hmm, alright. I'll do a double check again on my code first before using global because it seems to work for the other models but not for this specific View Model
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server