Resyncing the LINQ to SQL class model

Problem:

When you change the structure of your sql tables — say, change a type from a varchar to…  say an int — the linq to sql class model (eg. project.dbml) is not updated or sync’d.

Is there a way to sync the model with the db?

Solution:

1) One way is to delete the ‘table’ in the class model, then drag-n-drop / re-add it back.

2) Another work around:

1. Make the changes you want in the dbml file, and save it, if the designer did not regenerate the code:
2. Rename the dbml file (for example Northwind.dbml to Northwind2.dbml)
3. Make a copy of it (Drag it to the same folder)
4. Now rename the New file to the original name.
5. while renaming I found that the designer has regenerated the code file

Leave a Reply

You must be logged in to post a comment.