Search code examples
sqllinqentity-frameworkdata-migration

Can Linq to SQL create a database from DDL files?


Is there anything built into the Linq to SQL libraries that allow me to create an entire database from a collection of DDL files?

Lets say you have a collection of DDL files, one for each table in the database. Conceptually it would be pretty straight forward to call a create table function for each one and each one that succeeds (does not through SQL exception for example due to a relationship or foreign key error) pop the file name off the stack. For any that failed you could try to call the DDL again until it finally succeeded and all of your tables existed in the database ... however ... if there is something like this that already existed in say Linq to SQL or the Migrations project that would be great. Does anyone know if this exists already without having to combine all of the DDL's into a single script? Thanks in advance.


Solution

  • If you have Visual Studio 2008 or 2010 Professional or Above, it includes the new version of database projects. Which can handle that precisely for you (it will even validate the scripts before execution so you can see what errors exists).