views:

136

answers:

2

If you build the edmx file from the database and then the db changes, how do you get the model to pick up the change?

Do you delete the whole model and regenerate or can you detect changes?

I see a post mentioning a "Update Your Model" rt. mouse command on the edmx file, but I dont see it.

http://stackoverflow.com/questions/690248/updating-your-edmx-to-reflect-changes-made-in-your-db-net-linq-to-entities

I'm just starting out...

+2  A: 

Are you looking at the designer or code view? You can force the designer to open by right clicking on your EDMX file and selecting Open With -> ADO.NET Entity Data Model Designer

Right click on the designer surface of the EDMX designer and click Update Model From Database...

All entities are refreshed by default, new entities are only added if you select them.

JHappoldt
I did not see the "pen With -> ADO.NET Entity Data Model Designer" option when right mouse clicking on the edmx file, but th other option was available. I'd like to know why, but you provided a a valid answer. ty.
Velika
+2  A: 

I have found the designer "update from database" can only handle small changes. If you have deleted tables, changed foreign keys or (gasp) changed the signature of a stored procedure with a function mapping, you will eventually get to such a messed up state you will have to either delete all the entities and "add from database" or simply delete the edmx resource and start over.

Roman
The 'update from database' wizard replaces the SSDL but only applies some changes to the CSDL. As a result, when you have more complex changes the SSDL and CSDL tend to get out of sync, causing the 'messed up state' you're seeing.I have an add-in that addresses this issue for the EF4 designer in VS2010; it compares each of the three layers (DB, SSDL, CSDL), shows all differences and allows you to selectively sync up diffs. You can download the add-in and get a trial license at http://www.huagati.com/edmxtools/ if you want to try it out.
KristoferA - Huagati.com