How to update a DBML file whenever the db changes.
-
Tuesday, September 23, 2008 1:01 PM
Hi,
I'm new to LINQ, and I'm certain this isn't the first time this question has been asked. When I create a DBML file and create code using that particular DBML file, how can I update the DBML file periodically to reflect changes to my database? For instance, I may create a new table, new fields within tables and change the null/isnull values for the columns. Is there a way for the DBML file to update rather than deleting the dbml file? Do I have to delete the table within the dbml file and readd it?
Problem with deleting the table within the dbml and readding itis, if you renamed any of the field/properties within the table entity you'll have to rename all of them again.
Thoughts?
Thanks much
John
All Replies
-
Tuesday, September 23, 2008 1:15 PMHiif you change your table in the database you should delete the corresponding table from dbml file and add it again and the dbml file regenerate again , so your changes take effect.
-
Tuesday, September 23, 2008 1:20 PM
So there is no automatic sync process available? I heard something about using oSQL? If our dba applies numerous changes to the tables, then we'd have to have developers constantly adding removing the tables.
We also have some tables where we renamed the fields and DelayLoading property on some of the tables. Anyone else experience the same problem?
Thanks
-
Tuesday, September 23, 2008 2:39 PM
Hi John,
The same issue was annoying me for some time. After learning that MSFT wouldn't add that feature in SP1 (as I and many others had hoped for) I wrote an add-in that takes care of synchronizing the DBML against the database.
The add-in also comes with other additional features for the DBML (Linq to SQL) and EDMX (entity framework) designers; mass-renaming of entity types (classes), entity sets (accessor properties), members (properties) (L2S and EF), documenting L2S classes and properties from SQL Server's extended properties and index definitions etc.
You can download it and try it out if you want - see http://www.huagati.com/dbmltools/ for details.
Best regards,
Kristofer
-
Tuesday, June 23, 2009 6:17 PMYou can manually edit the dbml (xml) file. I would add the new class to another dbml file, then copy and paste the new XML definition into the old dbml file. This is an easy solution and does not require an unknown plug in that asks for $$ after 45 days.
-
Tuesday, March 08, 2011 8:12 PMHow do you add it back once you delete it from the dbml?
-
Tuesday, November 08, 2011 11:28 AMTry this Plug-in http://www.codeproject.com/KB/database/SqlMetalPlus.aspx
pvdp

