''Personal' is a type, which is not valid in the given context

I just created a new MVC Project and created an empty view. I wrote my first line of code while trying to declare the Model for the view which looks like following:

 @model Personal;

Where personal is a Model which actually exists. However, it is continuously showing me following error:

'Personal' is a type, which is not valid in the given context

I have no idea why something so simple can fail. I wish I could post more code but seriously there is nothing more to it, and I'm not sure why it is failing. I have browsed through some of the SO posts, but not one is having the same error at such a trivial location.

Any suggestions?



Solution 1:[1]

For me, it was a comment on the same line as the @model statement. Removed the comment and the error went away.

@model <namespace>.Model //A comment here can cause the error.

Edit:

After submitting the above the solution, the error was still there. After trying a few more ideas, I found that the @using statements below the @model statement also caused the error. I removed the @using statements and the error went away. I pasted the @using statements back in the same place and everything compiled and ran fine.

Note: Even with the above edit, a comment on the same line as the @model statement will still cause this error.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1