views:

943

answers:

3

I need to refresh a bunch of EDMX files in my solution. We have disected our tables into groups and each model represents one component or process. However, there are some overlapping tables, which means sometimes I need to refresh/update multiple Entity Models.

Refreshing a group of different entity models in VS 2008 is slow and dangerous. If I miss an out-of-date model, my application won't work

I need to verify that all of the models in my solution are up to date with my development database.

Ultimate solution: How can I script this? Is there an API to Visual Studio for refreshing an EDMX file? I do the exact same thing every time. Can't I program this?

Ok Solution: Can I set something up in Visual Studio to inform me when an Entity Model doesn't match a DB? What is the recommended way to test the model against a DB?

Thanks in advance.

+2  A: 

Check out the EDM Generator http://msdn.microsoft.com/en-us/library/bb387165.aspx

You could put in a pre-build event to regenerate the model. It's also wise to pre-generate the Views which increases performance substantially.

Hope this helps.

willbt
+1  A: 

As far as I can tell EdmGen will only work for WPF apps. Since you are looking to update a .EDMX file you will not have access to the xml files which the EdmGen tries to validate.

I would suggest checking the The ADO.NET blog: http://blogs.msdn.com/adonet/archive/2008/06/26/edm-tools-options-part-3-of-4.aspx

They have an explination of how to update an EDMX file but it is pretty involved. Hopefully VS10 will have a better solution for this.

johnnywhoop
just missing some samples
Junior Mayhé
A: 

Open the .edmx file in the Model Browser (double click it in VS.Net). Right-click anywhere and choose "Update Model from Database...". The wizard that opens up will show you a limited diff: new tables and deleted tables. But its granularity stops there. It doesn't show changes in fields, for instance.

xanadont