MVC View Scaffolding not working with Generic base class?

Is there a reason the built in MVC View Scaffolding in Visual Studio 2015 does not work with inherited base classes that contain a generic id? Simple test case:

public abstract class BaseEntity

public abstract class Entity<TKey> : BaseEntity
    public TKey Id { get; set; }

public class Country : Entity<int>
    public string Name { get; set; }
    public string CountryCode { get; set; }

Trying to create a scaffolded view (e.g. List, Create, Edit, Delete) using the Country entity results in the following error pop-up:

There was an error running the selected code generator: 'The method or operation is not implemented.'

If I remove the TKey type parameter and make Entity non-generic by defining a fixed type for Id, I can then scaffold the views.

I know in this simple case, I'm not saving myself much work by having the generic base class. I'm also aware that the "best practice" is to use View Models instead of Domain Models in your views. However, I'd like to understand why using a base class with a generic type is causing an issue with the scaffolding.


I also experienced that bug and found out it was already reported on Microsoft Connect. The only options we seem to have for now are:

  • Generating views from the controller by temporary removing inheritance (not a great idea though but could avoid loosing a lot of time)
  • Waiting for a fix from Microsoft

Note: It seems the same problem affects Visual Studio 2013 (Update 5) but I didn't find any bug tracker entry for that.

Should you want to follow the advancement of the bug fix or provide further information to the support team, you can pay a visit to Microsoft's bug tracker here:

Need Your Help

Disable task manager from a limited / guest account

c++ registry uac taskmanager

I am developing an application in c++ from which a user can disable task manager from within the application (and little more functions).

Google Maps v2 - set both my location and zoom in

android api google-maps google-maps-api-2

My question is, does anyone know how to set google maps up, to open up both my location and in a zoomed in view?