A primary key can be defined on a single, or multiple columns.
A table can only have one primary key. The most common form of a primary key is an identity column
on SQL data types such as int and bigint.
Take a look at Figure 10-1, which shows the table design for the Person.Contact table in the Adventure-
Works database.
Figure 10-1
210
Chapter 10: LINQ to SQL Overview
There are several things to notice. First, you can tell which column, or columns, are defined as the primary
key by the gold key displayed in the row selector. In this example, the ContactID column is designated
as the primary key. Second, the data type for the primary key is defined as an int, and the column does
not accept null values (the Allow Nulls box is not checked), which means that a value must be entered
into that column whenever a new row is added to the table.
The properties of the selected column display in the bottom pane. In this instance, it??™s the ColumnID
properties that are showing. The Identity Specification has been set to Yes, meaning that this is an identity
column, and you can set both an initial value (Identity Seed) and the value by which to increment each
new row (Identify Increment).
Pages:
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347