Geeks With Blogs

Blue Probe It’s the parting gift when you host an alien abduction

The ASP.NET apps I develop/support at work have all been WebForms. So while taking a lovely course by Scott Allen on PluralSight, I decided to skip the IOC crap in my lab. Wrong!  In order for the EF DBContext (interface) to be passed into the constructor for my controller, I need magic to occur. StructureMap provides this be giving my app a DBContext object each time the IDepartmentDataSource interface is asked for. See the following controller constructor:

  1. public DepartmentController(IDepartmentDataSource db)
  2. {
  3.     _db = db;
  4. }

What I don’t need is a default parameterless constructor. I could just create a new DBContext myself, but it seems Scott, and others, support this pattern in MVC. I’m not a big fan of magic because it becomes a maintenance nightmare, but alas…

Posted on Saturday, April 27, 2013 12:02 PM .NET | Back to top


Comments on this post: PluralSight MVC course error - No parameterless constructor defined

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Ken Hortsch | Powered by: GeeksWithBlogs.net