For others, I was getting this error. I had this in a _ViewImports.cshtml file. Turned out that I had written
@{ using class1; }
Rewriting it as @using class1; fixed the problem.
@using class1;