In fact, the controller is a class, a class that inherits from the controller. Create a controller normally, and the problem is that ASP. NET MVC provides a convenient way to create an action automatically when you create a controller.
1 Open the project, right-click on the Controller folder, select, create Controller
2 Enter the controller name, click OK; Note that controller names generally have controllers as suffixes
The 3 framework creates this controller, continues to self-controllers, and generates an action named index by default
4 The view is not actually generated automatically
5 if we want to automatically generate a set of action, such as additions and deletions, it is not more effort? In fact, supported. That is, when we created it, we chose an empty MVC controller, and we could choose a class that would allow the framework to automatically generate the corresponding action and view.
6 Create a new controller, choose to use the template, this template can meet our requirements above
7 First select a context, that is, the database represents the entity class, which we will enter a name when using EF to generate a database entity, typically the same name as the edmx file in model
8 then select a class (equivalent to a table in the database), so that we need to do a domain name additions and deletions function, then you can choose class domain; Click Add
9 If we want to specify a template for the view that will be generated, you can click Advanced options in the lower right corner, where you can specify a template layout
10 generate a good controller and its view; These functions are almost directly available except for some changes, which can save a lot of repetitive work
11 The function of the generator controller is introduced here for the time being, wish you to study happily!
I original, reproduced annotated source. Better visual typesetting please visit: Http://t.cn/RP6lxub