I am sure that the original poster still cannot find the answer by this time. but he can help seekers like me ..
This article has been discovered. Link
It seems that when going through the route Controller β Add β New forest item β MVC-controller with views, using the Entity Framework , does not work very well with view models.
If you did not provide the DataContext class in the aforementioned scaffolding process when choosing your view model, MVC scaffolding will not let you continue. As you indicated, the Add button is disabled.
The workaround is to take a two-step approach.
First create controller actions using scaffolding ( Controllers β Add β New Lining Element β MVC Controller with Read / Write Actions )
Then add views by right-clicking on individual controller action methods, and then using the forests. (Controller action method β ββRight-click β Add View β Template β [select anything, but Empty (without model)] β Model class β [select your viewing model here] β Leave the data context field blank β The add button will be enabled) .
The related article contains detailed instructions, please take a look.
However, you still need to add the code yourself to work with the database using the Entity infrastructure in the controllerβs action methods. (Or you can choose to enter layers, repositories, etc. YMMV ). But it helps to avoid writing a lot of code to create your views.
PS: I found that this approach works fine for me using ASP.Net core 1.1
source share