I have a table called countries
and I define the country_name
column to be unique by creating a “Index/Key” of type “Unique Key” on SQL Server 2008 R2.
If you are using SqlMetal.exe to output DBML or LinqToSql entities:
The reason is in the implementation of SqlMetal. It queries the database information schema, specifically key column usage. Unique keys are represented there, but unique indexes are not.
SELECT TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME, ORDINAL_POSITION
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE;