Sql – How to regenerate (update) LINQ to SQL DataContext

datacontextlinq-to-sqlvisual-studio-2008wpf

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?

Best Answer

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.