0A\bin directory.
OK, now for some examples. Like the process outlined, the first step is to extract the metadata into a
.dbml file. So, the following example creates a .dbml file that contains extracted SQL metadata from the
AdventureWorks database, creating a file called aw.dbml. This is achieved by executing the following
sqlmetal /server:avalonserver /database:AdventureWorks /dbml:aw.dbml
Figure 15-13 shows how this is executed in a command window.
297
Part III: LINQ to SQL
Figure 15-13
After the command successfully executes, browse to the directory where the SqlMetal tool is located
(\Program Files\Microsoft SDKs\Windows\v6.0A\bin), and you should see in the directory a filed called
aw.dbml. You can also specify a location when generating the metadata, as illustrated in the following
code:
sqlmetal /server:avalonserver /database:AdventureWorks /dbml:C:\wrox\aw.dbml
The next step is to generate the code, which is shown in Figure 15-14. This example specifies the language
and the code file to generate.
sqlmetal /server:avalonserver /database:AdventureWorks /code:aw.
Pages:
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474