Generate a Database using LinQ to SQL DBML file

linq-to-sql

I just inherited a project with LinQ to SQL Database file. I need about half of the 100 plus database tables so I would like to Generate a database based off the DBML file and strip out the stuff I dont need.

Is there a way to do this?

Best Answer

http://msdn.microsoft.com/en-us/library/bb399420.aspx

In LINQ to SQL, an object model is mapped to a relational database. Mapping is enabled by using attribute-based mapping or an external mapping file to describe the structure of the relational database. In both scenarios, there is enough information about the relational database that you can create a new instance of the database using the DataContext.CreateDatabase method.

The DataContext.CreateDatabase method creates a replica of the database only to the extent of the information encoded in the object model. Mapping files and attributes from your object model might not encode everything about the structure of an existing database. Mapping information does not represent the contents of user-defined functions, stored procedures, triggers, or check constraints. This behavior is sufficient for a variety of databases...

This should do the trick