Is there a reason why the built-in MVC View Scaffolding in Visual Studio 2015 does not work with legacy base classes that contain a common identifier? A 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; } }
An attempt to create a view in the form of forests (for example, "List", "Create", "Edit", "Delete") using the "Country" object will result in the following error pop-up window:
An error occurred while starting the code generator: "Method or operation not implemented."
If I remove a parameter of type TKey and make Entity non-generic by defining a fixed type for Id, I can then raise the views.
I know in this simple case, I do not save a lot of work, having a common base class. I also know that the โbest practiceโ is to use view models instead of domain models in your views. However, I would like to understand why using a base class with a common type causes a problem with scaffolding.
source share