Reputation: 344
I want to create a non clustered but unique index on two columns. I tried:
Map(x => x.Col1).Index("IX").UniqueKey("IX");
Map(x => x.Col2).Index("IX").UniqueKey("IX");
and got non-unique index and additional unique constraint (switching order doesn't help),
or:
Map(x => x.Col1).Index("IX").Unique();
Map(x => x.Col1).Index("IX").Unique();
and got non-unique index and 2 additional unique constraints (switching order doesn't help).
Is there a way to create only the index, but unique?
Upvotes: 0
Views: 2141
Reputation: 5362
If I leave out the .Index()
and just write
Map(x => x.Col1).UniqueKey("IX");
Map(x => x.Col2).UniqueKey("IX");
I get a unique nonclustered Index in SQL 2008 Express (R2) without any additional constraints. (At least that is displayed when I view the porperties in the SQL Management Studio.)
Upvotes: 2