The Add View dialog box does not work in an MVC 5 project that refers to an F #

advertisements
  1. Using Visual Studio 2013, create a new ASP.NET Web Application project using the MVC template. Verify that the Add View dialog functions by right-clicking the "Views\Home" folder and choosing "Add... View".
  2. Now add a new F# Library project to the solution. The Add View dialog should still function correctly.
  3. Now add a project reference from the MVC project to the F# project by right-clicking the References folder, choosing Add Reference, Then browse to Solution...Projects on the left and checking the F# library project that you just added.

At this point, if you right-click the "Views\Home" folder and choose "Add... View" you will get an error in a pop-up alert box instead of the Add View dialog:

There was an error running the selected code generator: 'Object reference not set to an instance of an object.'

Workarounds include, but are hopefully not limited to:

  • Remove all your references to any F# projects every time you want to add a new view.
  • Unload any referenced F# projects, but leave the project references in place, every time you want to add a new view.

My questions are:

  • Are other people seeing this behavior, or is it just me?
  • Does anyone know of a better work-around than removing references or unloading F# projects?
  • Does anyone know if Microsoft is already working on fixing this? If not should this be reported to the F# team or the Visual Studio team?

Between this issue and the fact that it is still impossible to use NuGet to add an Entity Framework 6 reference to any F# project, I'm starting to get nervous about Microsoft's level of commitment to the F# language.


Not sure if this will help you but check the version of EntityFramework in your solution. I had two projects within my solution and for whatever reason, the web project had EF 6 and the class library project was EF 6.1. Once I uninstalled EF completely from the solution and reinstalled EF 6.1 on both project, the "Add new view" action started working.