Razor views are dynamically compiled by the ASP.NET runtime. If you want your views to be built at compile-time you could add the following option to your .csproj file:
<PropertyGroup>
<MvcBuildViews>true</MvcBuildViews>
</PropertyGroup>You may take a look at the this article for more details.
Source: asp.net mvc – razor views are not giving compile time error – Stack Overflow