0

I'm using Visual Studio 2017, v15.3.1 and am trying to follow a tutorial about creating some WebAPI endpoints with Entity Framework, as outlined here

In my case I'm using the good old Northwind SQL database instead of the author's blogging example, which I don't think should be an issue?

At any rate, when I get to the bit where I'm supposed to create a controller, I right-click the controllers folder in my solution, select 'API Controller with actions, using Entity Framework' and choose my EF model class (Orders, Employees, it doesn't seem to matter) and the Data Context which I generated successfully earlier in the tutorial.

When I select Add there's an attempt to scaffold, but I'm then told in a popup: There was an error running the selected code generator: 'No parameterless constructor defined for this object'.

I've looked at this error message online and others have had similar problems, but nothing they tried quite matches my scenario, and their solutions haven't fixed this issue.

My generated EF model classes do have parameterless constructors defined, so I'm not sure what the error is referring to?

jkj2000
  • 1,563
  • 4
  • 19
  • 26
  • 1
    The error is complaining about the context, not the entity class(es). You're probably using EF Core, rather than EF6, and EF Core's `DbContext` does not have a parameterless constructor. There's either some conflict somewhere or the tooling is borked for some reason. – Chris Pratt Oct 26 '17 at 21:35
  • Thanks for the reply. I was wondering about that-- I can try these same steps without ASP.Net and EF Core, though would prefer to be able to use them. – jkj2000 Oct 27 '17 at 03:17

0 Answers0