Hooked on LINQ

Hooked on LINQ - Developers' Wiki
for .NET Language Integrated Query

Quick Search

Advanced Search »

SQL Metal

Modified: 2007/01/04 23:28 by t_magennis - Categorized as: LINQ to SQL
SqlMetal is a command line generator that builds the OR types used by LINQ to SQL. It reverse engineers a given database.

C:\Program Files\LINQ Preview\Bin>sqlmetal.exe
usage: sqlmetal [options] [<input file>]
options:
  /server:<name>     database server name
  /database:<name>   database catalog on server
  /user:<name>       login user id
  /password:<name>   login password
  /views             extract database views
  /functions         extract database functions
  /sprocs            extract stored procedures
  /xml[:file]        output as xml
  /code[:file]       output as source code
  /map[:file]        generate xml mapping file instead of attributes
  /language:xxx      language for source code (vb,csharp)
  /namespace:<name>  namespace used for source code
  /pluralize         auto-pluralize table names
  /dataAttributes    auto-generate DataObjectField and Precision attributes
  /timeout:<seconds> timeout value in seconds to use for database commands

examples:
To generate an XML file with extracted SQL metadata
  sqlmetal /server:myserver /database:northwind /xml:mymeta.xml

To generate an XML file with extracted SQL metadata from an .mdf file
  sqlmetal /xml:mymeta.xml mydbfile.mdf

To generate source code from an XML metadata file
  sqlmetal /namespace:nwind /code:nwind.cs /language:csharp mymetal.xml

To generate source code from SQL metadata directly
  sqlmetal /server:myserver /database:northwind /namespace:nwind /code:nwind.cs /language:csharp

An alternative entity generator that uses XSL as a template language by Dan Radu can be found here: DLINQ Entity Generator.

If you would like to comment on this page, click on the Discuss button located on the top-right of each page. Feel free to edit any mistakes or ommissions you find. If you have an objection or find in-appropriate content then contact the administrator. This website is not affiliated with Microsoft®, all content and opinions are those of the specific author and some advice, solutions and article may contain un-intentional errors - please use care. Powered by ScrewTurn Wiki version 2.0.33. Some of the icons created by FamFamFam.