How to generate LINQ to SQL Mapping

You may or may not have come across the ability within LINQ to SQL to have mapping to and from your own objects.

Microsoft has a mapping builder called sqlmetal, which is a code generation tool to generate the mapping automatically.

Here is a sample command line to generate the mapping file.

[code language=c#]

sqlmetal /server:. /database:mydb /map:mydbMappings.xml /code:code.dbml