views:

46

answers:

4
+1  Q: 

update .dbml file

How to update .dbml file after making some changes in the database.

+3  A: 

The only way to do this is to delete the objects from the dbml interface, and re-add them back. Make sure that you hit Refresh in the Server Explorer panel after making changes to the database so that Visual Studio picks up the latest changes to the database when it creates the objects in the dbml.

Tim S. Van Haren
Or use the Huagati EDMX/DBML tools ..... http://www.huagati.com/dbmltools/
marc_s
+2  A: 

SQLMetal is the tool you want. It installs with Visual Studio as part of the SDK. For most dbml, however, I've found the delete/re-add technique to be a bit more expedient and reliable.

rtalbot
+1  A: 

There is no way to auto refresh the DBML to match the database. If you have added new tables to the datbase you can simply drage them into the designer window. If you have added or changed fields on existing tables or altered foreign keys/relationships, your best bet is to manually edit the classes and properties in the DBML file. ~You can delete them and the drag them back in from server explorer which will refrech them from the datbase but you will lose any custom modifications you have made such as changing properties from public to protected or setting up inhertance or other things.

Ben Robinson
+2  A: 

There's no built-in way to sync the dbml file/datacontext with the database after making changes (besides regenerating the entire dbml file by removing all or a selection of the entities and re-dragging them, or by using sqlmetal as suggested by other replies), but there are third-party tools that add refresh functionality to the Visual Studio L2S designer.

One such tool is my add-in, Huagati DBML/EDMX Tools. You can download it from http://www.huagati.com/dbmltools/ and get a trial license if you want to take it for a test spin.

Jim Wooley has a summary various Linq and Linq-to-SQL tools here:
http://www.thinqlinq.com/default/LINQ-Tools.aspx

...and Damien Guard has a list of tools/resources for L2S here:
http://damieng.com/blog/2009/06/04/linq-to-sql-resources

KristoferA - Huagati.com