MVC Controller Scaffolding Fails if Class Inheriting DbContext also Implements an Interface - by Peter87

Status : 

  Not Reproducible<br /><br />
		The product team could not reproduce this item with the description and steps provided.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 771486 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 11/17/2012 8:11:09 AM
Access Restriction Public


When defining a DbContext class to use in Entity Framework 5 Code First, it is helpful to make the class implement an interface so that it can be injected and mocked. However, Visual Studio 2012 appears to have a problem with this in MVC 4 applications. If the class inheriting from DbContext implements an interface, even an empty one, controller creation with view scaffolding fails.
Sign in to post a comment.
Posted by Microsoft on 3/4/2013 at 4:58 PM
I was unable to reproduce this. I am using VS 2012 Update1 and the release version of "Microsoft ASP.NET and Web Tools 2012.2" and Windows 8. Could you please what versions of the following are you using in your scenario:

1. Visual Studio
2. MVC4
Posted by Vairam Vairaperumal on 12/6/2012 at 10:38 AM
This bug is reproducible in Visual Studio 2010 with EF 5.0 and MVC4.0 as well with .NET 4.0.3 updated and November 2012 update for SSDT applied as well.
Posted by Vairam Vairaperumal on 12/6/2012 at 9:15 AM
I also received the same error.
Posted by ak99372 on 11/28/2012 at 6:26 PM
Same applies if DBContext has additional functionality with partial class
Posted by Peter87 on 11/22/2012 at 8:24 AM
I tried disabling the VSCommands plugin in my real project and I still get the error. My real project is more complicated than the sample provided. Oddly, generating individual controllers and views is working.
Posted by Microsoft on 11/21/2012 at 5:45 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Peter87 on 11/20/2012 at 1:53 PM
This was an issue in VS 2012. Running in safe mode let scaffolding work properly. I disabled some extensions one by one and found that VSCommands for Visual Studio 2012 ( was causing the issue.
Posted by Microsoft on 11/19/2012 at 8:22 PM
Thanks for your feedback.

Which version of VS are you using? And can you repro it with VS in safe mode?

Please submit this information to us within 3 business days. We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 11/19/2012 at 9:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(
Posted by rebel1970 on 11/18/2012 at 2:57 PM
I was able to reproduce this issue.