runtime icon indicating copy to clipboard operation
runtime copied to clipboard

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

Open aswanevelder opened this issue 8 years ago • 2 comments

Steps to reproduce

  • Create Code-First model, I called it MyModel with a single property MyModelID
  • Right click on Controllers, choose Add controller
  • Choose MVC Controller with views, using EF
  • Choose Add
  • Error

Expected behavior

  • Controller and Views to be created

Actual behavior

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

Environment data

Visual Studio 2017 .Net Core 2.1.4 Microsoft.VisualStudio.Web.CodeGeneration.Design (v2.0.1)

aswanevelder avatar Dec 22 '17 15:12 aswanevelder

It seems that the data context does not default anymore and out of habit I did not even bother, but choosing a context now seems to eliminate this issue.

aswanevelder avatar Jan 02 '18 10:01 aswanevelder

Hey! I don't know whether this issue was solved or not, but I was facing the same problem while creating empty API Controller. What helped in my case is that I had wrong CodeGeneration.Design package installed, so I went to nuget package manager and deleted my CodeGeneration.Design package and then when tried to scaffold new controller it installed the required CodeGeneration.Design package itself. In case you are looking for the package itself it is Microsoft.VisualStudio.Web.CodeGeneration.Design

faridhuseynov avatar Dec 08 '19 17:12 faridhuseynov