如何表示主鍵

在ColumnAttribute屬性上使用 LINQ to SQL IsPrimaryKey 來指定某個屬性或欄位為資料庫欄位的主鍵。

關於程式碼範例,請參見 IsPrimaryKey。

備註

LINQ 對 SQL 不支援計算欄位作為主鍵。

指定屬性或欄位為主鍵

  1. 將 IsPrimaryKey 屬性添加到 ColumnAttribute 屬性中。

  2. 指定值為 true。

另請參閱