Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to regenerate (update) LINQ to SQL DataContext?

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?

like image 810
rem Avatar asked Jan 11 '10 19:01

rem


People also ask

What is DataContext in Linq?

The DataContext is the source of all entities mapped over a database connection. It tracks changes that you made to all retrieved entities and maintains an "identity cache" that guarantees that entities retrieved more than one time are represented by using the same object instance.


1 Answers

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.

like image 185
Geoff Appleford Avatar answered Nov 16 '22 11:11

Geoff Appleford