ASP.NET MVC Scaffolding for any table

Asked

Viewed 261 times

5

Someone knows a way for me to generate CRUD automatic to my bank tables using MVC?

I have 5 tables and would like to generate SinglePage apps automatically for them, without having to generate several views/controllers. The idea is to create basic administration screens to manage these tables that are my internal control and do not need worked designs.

The idea is if another table appears in the future I just need to select in a combobox which I want to manage and already be listed the values on the grid with buttons insert/update/delete.

I’ve already researched some things but what I find still requires considerable work to do the Scaffolding and creates multiple files views/controller.

  • You want to celebrate Views from your database?

  • @rodrigorf You are using Code First?

  • @Renancarlos Database First.

  • @Jcsaint, exactly, generate the views/controllers, but wanted to know if there is a way to generate a generic view/controller that suits several tables. If not possible, at least generate everything automatically and already with CRUD methods.

1 answer

3


Yes, using the Entity Framework Power Tools.

Only there is a problem: this tool, besides being a Beta, has not been updated to Visual Studio 2015.

So, this guy updated the tool for us. The link to her is here.

After installing VSIX, you will need to go back to the . NET Framework for version 4.5.1, otherwise it will not work.

Framework 4.5.1

Once done, right click on your project and select the option Entity Framework > Reverse Engineer Code First.

Reverse Engineer Code First

Choose the server and database name you want to do the Scaffolding. The tool will replicate to the code all tables of the selected database.

Connection Properties

If everything was done right, the tool will do the Scaffolding in the background.

Two observations:

  1. The tool creates a directory called Mapping with entity mappings in separate classes. It is not incorrect to use this way, but should be discouraged because it is an old and prolific approach, which makes it difficult to maintain the project;
  2. The tool does not Scaffolding of Controllers and Views: only of Models. For the other items of Scaffolding, you will have to use the Scaffolding native or the Mvcscaffolding.
  • I appreciate the post very complete Gypsy, so I understood apparently I will not find a tool that manages these controllers/views for me in an easy way, but I got the feeling that this Power Tool generates only Entities without CRUD, correct me if I’m wrong, I will test :). Another thing, you commented about not being good practice using this model of Mapping, would indicate another way?

  • Doing everything in a tool just doesn’t exist, in fact. A lot of mapping information doesn’t need to be used because the actual Model already expressed the relationship. Other information can be replaced by decoration of attributes. In this case, you would need to modify the Model brought from the bank to then eliminate the mapping class.

  • Show. Already makes my life easier anyway. Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.