Update MVC database first to reflect db changes

asp.net-mvc-4 c# ef-database-first entity-framework sql-server-2008

Question

i'm new to MVC and have to update my model.

I have an SQL Server database already connected to my project, today I add a new column. Now I need to update my MVC code to reflect the change.

Everything online tells me to update the .edmx and .tt files with the Update Model Wizard since they are auto generated, but I cannot find the wizard in VS 2012 so I am at a stand still.

Is this the right way I should be doing this? Any tips would be great...thanks

1
0
9/24/2013 5:30:11 PM

Accepted Answer

I ended up downloading this update of VS 2012 and repaired. Now I am able to update my model.

1
9/24/2013 7:39:41 PM

Popular Answer

Double click the edmx file. This opens the diagram of the database model. Right click and select "Update Model from Database..." That will start the wizard you're looking for.

Be aware that not all changes come through automatically.
Most obvious is that columns will not be removed from model just because they're gone from the db. If you're dealing with lots of modifications or deletes rather than additions, it may be best to just drop the model and recreate it (as suggested above by Andrew).
No matter which approach you take, I'd suggest making sure you have all other local source changes committed or shelved before starting because you may need to do an undo check out if EF gets freaked out.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow