views:

38

answers:

3

When I modify the structure of the table in Sql Server ,won't it be automatically reflected in the "Dbml" Layout designer ?Each and every time i have to delete the tables in "dbml' layout designer and drag the table from sql server.

A: 

If I were you I'd start using SqlMetal. SqlMetal is a command line application used for generating LINQ DataContexts. It can generate dbml's or just a set of classes for you to use in your project (it's pretty customizable). So create a batch file that calls SqlMetal and run it every time you make database changes and your project will always be up to date with the database.

If you don't want to run the batch file every time you update the database you could just run it every time you build your application with a pre-build step.

Jason Punyon
+2  A: 

It would be nice if you had the option to "refresh" keeping any local customizations that you've made, but the designer doesn't seem to work that way. You can, however, simply make the same updates (by hand) in the designer that you've made to the table by adding/deleting columns from the generated class in the designer.

tvanfosson
A: 

There are a number of ways to keep the L2S model in sync with the underlying database:

1) Delete the table(s)/classes involved from the designer surface and drag them back from the 'server explorer' thing.

...or...

2) Update the classes involved manually in the L2S designer.

...or...

3) Use third party tools with update capability (one such tool is my add-in: http://www.huagati.com/dbmltools/ , also mentioned in the Dec 2009 issue of MSDN magazine http://msdn.microsoft.com/en-us/magazine/ee819138.aspx)

...or...

4) Regenerate the entire DBML file using either the designer or sqlmetal.exe.

KristoferA - Huagati.com

related questions