views:

1004

answers:

1

I'd like to have a single source of the description of the data structure.

Some people are asking can the DBML file being refreshed when it is changed in the database. The way I do is stupid but common; open it, delete all, and drag-drop again. I heard that there are some 3rd party do the tricks.

But I am thinking, any way to inverse the operation?

In hibernate, there is a way to build the DDL of the target DB from the XML data structure.

Is it possible that the DBML file will contain all information to rebuild the DDL of the database? (e.g. have a copy of those VIEW SQL, stored procedure codes), and build the "Create script" on the fly (like what you do in SQL Server Enterprise Manager)

A: 

The DBML file only contain tables, columns, foreign key constraints, and primary keys. Views are stored in the same way as tables, so the only information stored is the name of the view and what columns (w/ type, nullability etc) that it return. The view definition itself is not stored and therefore not possible to extract from the dbml file.

If you use the L2S designer and the underlying DBML file for data modelling you will lose:

  • non-PK indexes / keys
  • view definitions
  • stored proc definitions
  • function definitions
  • alias types
  • ...etc...

That said, if you want to generate the SQL-DDL for table defs, FKs, PKs etc from your DBML, my add-in for Visual Studio can do that for you. (It supports sync both ways db -> dbml, and dbml -> sql-ddl -> db You can download it and get a trial license from:
http://www.huagati.com/dbmltools/

KristoferA - Huagati.com
I downloaded this tool and this was the output I got from it for creating the table I wanted the sql script for `Create Table . ( , , , , , , , , );` Not very helpful.
Chris Marisic