Upgrading to Visual Studio 2015 makes intellisense broken for a project

I had many similar problems, but I could not find anything that would work for me.

I am upgrading my IDE from VisualStudio for the Web (v10) to Visual Studio 2015 (v14, I think) Community Edition. The main project I'm trying to use on the new IDE is MVC 5 (5.2.3), with EF 6.1 (6.1.3) and many other things.

The problem is this: when you open a project on the new IDE, everything looks fine (it even compiles and works). I got the MVC context menu working on the project explorer (if necessary, specifying "Add controller ..." and "Add view ..."). Only (very annoying) thing is Razor Intellisense.

When I open a View file (.cshtml), I get warnings about several helpers, some of the "uses" are grayed out (although they should be necessary), and @model myModel is shown as everything after the @model directive is not a razor (it was processed as HTML using intellisense coloring).

What I already found and tried:

    • I already tried to clear UserData from vs (devenv / ResetUserData)
    • I already tried to start VS2015 in safe mode
    • I already tried to run VS2015 as administrator
    • I already tried to set the target structure of Project 4.5.1 (used to be 4.5)
    • I already tried to open the project on Visual Studio Community 2013, saving it there before trying to use it on VS2015.

When you create another MVC project from VS2015, everything works fine.

Here is an example of an annoying problem:

enter image description here

+6
source share
1 answer

Good, finally understood. Pursuing what I learned, believing that this might help someone else:

  • It seems that the problem is due to the fact that the project was created on an old version of MVC (with older Razor, EF, etc.).

  • As indicated in this answer: Visual Studio 2015 Razor View MVC types are not recognized , VS2015 tools may not work for older MVCs.

  • The solution is to upgrade all of your packages to [at least] the minor versions adopted on the new MVC (5?). To do this, you can use the list on this site: http://www.asp.net/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to- aspnet-mvc-5-and-web-api-2 .

  • Once everything is updated, open the web.config files located in the root folder of the application and in the "Views" folder. There you will probably find some links to older versions of MVC and Razor. Update these version values ​​(all of them) according to the updated versions of your packages (you can create a new empty MVC project in the new Visual Studio and check these values ​​as a hint that they should be).

    This step is a catch! Since even if you are updating project packages, some links to web.config may still mention the original versions.

  • Clean the solution (Build> Clean Solution) and close the project. Reopen and compile it. Now [hopefully] everything should work fine.

[change]

  1. One more thing. If your project was also upgraded from Framework 4.5 to 4.5.1 during this IDE transition, you should also install a NuGet package called "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" (as stated at https://support.microsoft.com/ en-us / kb / 3025133 ).
+6
source

All Articles