Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate a Database using LinQ to SQL DBML file

Tags:

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?

like image 842
jquery auth Avatar asked Aug 13 '10 09:08

jquery auth


1 Answers

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

like image 152
Migol Avatar answered Oct 16 '22 19:10

Migol