Generating Entity Classes Using SqlMetal.exe
Our first LINQ to SQL example was fairly simplistic, partially due to the fact that our DataContext
was operating on a single data table. A production-level LINQ to SQL application may instead be
operating on multiple interrelated data tables, each of which could define dozens of columns. In
these cases, it would be very tedious to author each and every required entity class by hand. Thank-
fully, we do have two approaches to generate these types automatically.
The first option is to make use of the sqlmetal.exe command-line utility, which can be exe-
cuted using a Visual Studio 2008 command prompt. This tool automates the creation of entity
classes by generating an appropriate C# class type from the database metadata. While this tool has
numerous command-line options, Table 24-2 documents the major flags of interest.
Table 24-2.
Options of the sqlmetal.exe Command
Do'stlaringiz bilan baham: |