Analyzing LINQ to SQL Source Code

By using the following steps, you can produce LINQ to SQL source code from the Northwind sample database. You can compare elements of the object model with elements of the database to better see how different items are mapped.

Note

Developers using Visual Studio can use the O/R Designer to produce this code. Object Relational Designer (O/R Designer)
Object Relational Designer (O/R Designer)

  1. If you do not already have the Northwind sample database on your development computer, you can download it free of charge. For more information, see Downloading Sample Databases (LINQ to SQL).

  2. Use the SqlMetal command-line tool to generate a Visual Basic or C# source file. For more information, see Code Generation Tool (SqlMetal.exe). By typing the following commands at a command prompt, you can generate Visual Basic and C# source files that include stored procedures and functions:

    • sqlmetal /code:northwind.vb /language:vb "c:\northwnd.mdf" /sprocs /functions /pluralize

    • sqlmetal /code:northwind.cs /language:csharp "c:\northwnd.mdf" /sprocs /functions /pluralize

See Also

Other Resources

Reference (LINQ to SQL)

Background Information (LINQ to SQL)