Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating scaffolded controllers and views with model changes

For the basic functionality of my project I've been defining Entity Framework models and then using the scaffolding feature of Visual Studio to implement CRUD functionality (Right Click -> Add -> New Scaffolded Item...).

If I need to make a change to the model after I've done this, how do I make the scaffolded controllers and views update to the latest model changes? For example, I'm seeing the need now to add a new attribute to my model and change the data type of an existing one, but the controllers and views likely won't work after the change.

I could always just re-scaffold, but I've made some changes to the controller and views already which I don't want to lose. Is my only solution to make the changes myself?

like image 233
John Dorean Avatar asked Jan 17 '15 20:01

John Dorean


Video Answer


1 Answers

Rename the files having your changes, scaffold again, and replace the newly-scaffolded files with your originals.

Naturally, you'll have to reconcile any domain changes that were made to the files containing your changes.

like image 194
Robert Harvey Avatar answered Oct 03 '22 23:10

Robert Harvey