Creating/Configuring the DataContext
When you add the O/R Designer by adding the LINQ to SQL Classes item to your project, the designer
opens in design mode automatically. Figure 15-3 shows what the O/R Designer looks like when it is
first created. The O/R Designer design surface has two areas with which to work and design your data
classes. The left pane is the Entities pane (or Entity Class pane), the main location where entity classes
will be defined. The right pane is the Methods pane where DataContext methods are mapped to stored
procedures and functions. The methods pane can be hidden; the entities pane cannot.
288
Chapter 15: Advanced LINQ to SQL Topics
Figure 15-2
Figure 15-3
When the O/R Designer is first opened, it is empty of any objects, as Figure 15-3 shows. It represents
an empty DataContext ready for configuration. Configuring the DataContext is as simple as dragging
objects from the Server Explorer in Visual Studio to the Entities pane in the O/R Designer and setting the
appropriate connection properties.
For example, the first time you drag a table from the Server Explorer to the Entities pane, you may receive
a message (see Figure 15-4) asking if you want to save the connection information corresponding to this
object and the Server Explorer Data Connection with the DataContext and the O/R Designer.
Pages:
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462