0

I am using VS 2017 and trying to create "Web API 2 OData v3 Controller with actions, using Entity Framework". This was working without issue earlier.

Today when I tried it, it failed with below error message.

Object reference not set to an instance of an object.

enter image description here

I followed below steps but it did not worked,

  1. Delete folder C:\Users\userlogin\AppData\Local\Microsoft\VisualStudio
  2. Delete folder C:\Users\userlogin\AppData\Local\Microsoft\VSCommon
  3. run command devenv /resetuserdata

Is there a way to get the actual error or am I missing something?

Ravi Khambhati
  • 637
  • 1
  • 12
  • 35
  • Whenever something used to work and doesn't work now, ask "what changed?" Question your assumptions if your answer is "nothing". Start with leveraging your source control solution to answer the question. Pretty much everything that can muck up things when using abstract, code-generation tools is mucked up in a file changing something somewhere. – Michael O'Neill Dec 19 '17 at 19:35
  • I undo everything and then tried but no luck. Is there a way I can get an actual error rather than this generic message? – Ravi Khambhati Dec 21 '17 at 19:57
  • I empathize with you. I have also in the past had issues with mystery issues with the code generation from EF. Here are the only feasible hints I can provide: Make sure you have the latest packages associated with your project. Add, then remove via NuGet. Sometimes that helps. Or, begin a new project and bring one piece at a time from the dysfunctional project. Good luck. Rest assured, though, something changed. You just don't know what it is. Saying "I undo everything" isn't enough; more diligent source control going forward is the ultimate solution for you. – Michael O'Neill Dec 21 '17 at 21:50
  • 1
    I think we were typing the same time :). Updated to latest version of Entity Framework did the trick. – Ravi Khambhati Dec 21 '17 at 21:52

2 Answers2

0

After going through below thread I felt that issue is with Entity Framework and when I looked at Entity Framework, found that I was using "6.1.3" version whereas latest version is "6.2.0". When I updated to latest version everything started working as expected.

"There was an error running the selected code generator" in VS 2013 scaffolding

Ravi Khambhati
  • 637
  • 1
  • 12
  • 35
0

After trying a number of solutions recommended on a different S.O. post (link coming shortly) I finally settled in on my issue:

My business entities project and by EF context projects were my first attempt to use .NET Standard

My web app was a .NET Framework app. Getting rid of the .NET Standard projects allowed everything to work (I converted them to traditional .NET Framework projects)

bkwdesign
  • 1,953
  • 2
  • 28
  • 50