views:

1012

answers:

2

Really stupid question, sorry, but I can't find it on google (I'm sure it's in a screencast or something somewhere). I have a DBML (linq2sql classes) diagram and I've changed the underlying database. In VS2008, how do I "refresh" the diagram? There's no View-->Refresh or RightClick->Refresh or Update option.

As it stands now, I have to recreate the entire linq2sql classes every time I update the underlying db.

+4  A: 

right click and select "run custom tool" (in solution explorer on dbml file)

Ali Shafai
Well that's a bit non-intuitive. Thanks!
Chris
hell yeah, it took me some time to discover "custom tool" is actually the thing that generates the calsses :)
Ali Shafai
That doesn't update the DBML file with database changes. It triggers the code generator that generates C# or VB code from the DBML file. DB changes still need to be propagated to the DBML file one way or another - see my answer.
KristoferA - Huagati.com
@Chris: Are you sure it works? Seems to do nothing...
Yan Sklyarenko
A: 

If you want to bring database changes into your DBML diagram then you can:

a) remove the changed entities from the designer diagram and re-drag them. You will lose any customizations (e.g. class and property name changes etc).

b) manually update the diagram, adding/removing classes, member properties, etc.

c) Use a third party tool capable of comparing and updating the DBML file with the underlying database. One such tool is my add-in, Huagati DBML/EDMX Tools. It adds a bunch of features to the L2S designer in VS2008 and VS2010, including update/sync, comparison, mass-renaming, name rule enforcement, documentation from extended properties/indexes/etc, multiple 'views' per dbml diagram etc.

KristoferA - Huagati.com