views:

359

answers:

2

I use LINQ to SQL in a WPF project. I have made small changes in the database (changed datatype of the fields, which contain no data).

Now I want to regenerate (refresh) the LINQ to SQL DataContext of this project (I use VS 2008). I try to right-click on .dbml item in my Solution Explorer and choose "Refresh", but nothing happens.

How could I update the DataContext in a Visual Studio 2008 WPF project?

+4  A: 

Without resorting to some 3rd party tools, the easiest way is just to delete the modified tables from the designer and drag them back in from Server Explorer.

Unfortunately, if you've made any manual modifications in the L2S designer they wont be preserved and you'll have to manually make the changes again.

huagati has a tool that claims to be able to refresh changes but I haven't tried it myself.

geoff
+1 Indeed, no easy way to achieve that barring deleting and readding the table.
Aviad P.
Yes, it works OK. Thanks! +1
rem
+1  A: 

As other answers have stated it can only be done by deleting and re-adding the table. If you later move to Entity Framework however there is the ability to do exactly what you are looking for (there will be an "Update Model from Database" option in the context [right click] menu).

mynameiscoffey
+1 for the info
rem