In Visual Studio 2010 EF 4, I could add a new column to a database table, then click 'Update Model from Database' on my .edmx and all was good in the world.
In Visual Studio 2012 EF 5, I alter a table, and then click 'Update Model from Database' and it does not pick up the changes to individual tables anymore.
Am I missing something ... or is this a new 'feature' of VS2012?
Update The only way I can get a table with an added column to reflect in the .EDMX file is to delete the table then 'Update Model from Database' and it will pick up the added column. However, it puts the added table far off to the left and I have to move it back in place. No biggie just an annoyance.
Update the .edmx file when the Database changes In the Model Browser, right-click the . edmx file and select Update Model from Database. Expand the Tables, Views, and Stored Procedures nodes, and check the objects you want to add to the . edmx file.
Use the update model wizard (to update the storage model), open the . edmx file using the XML editor, find the desired property in the CSDL (conceptual model) section and change the desired attributes. This is basically the same as option 1, but you're editing the XML directly (a find and replace might be useful here).
The easiest way to resolve this issue is to right click on the Entity Model and choose "Update Model From Database". Then select the "Refresh" tab and find and select only the table you wish to map a column for. Click the Finish button and you should have everything properly mapped.
Yes, this still works in VS2012. Are you using the default code generation or do you have a TT file? It could be that it's being added to the EDMX but your class files are not being updated.
Try right-clicking on the EDMX file or the relevant TT file in Solution Explorer and choose "Run Custom Tool" to make sure it's being regenerated.
There is a difference between having an EF Model and how it is underlined in your database. When you "Update model from database", if the entity/table is already imported into your data model then you will be refreshing the entity. This process will not automatically map your database schema to your existing data model, you can however add a property to the entity in your EF model, and then map the property to the database column (this is exactly what EF does for you automatically when you delete and update normally).
When you delete the entity first, then update EF knows that the table/entity has not been imported before and so will map all of the database columns automatically for you.
In summary, you don't HAVE to delete the entity, but it can be easier to do so for simple entities.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With