Reputation: 703
I am trying to add a new column as Unique key where the table has already data. I am using EF 6.0 and code first approach and I added the property [Index(IsUnique = true)] and generated the Migration Script but when executing I am getting an error as the column added is new and there is no value to it
Upvotes: 0
Views: 388
Reputation: 342
Try this.
[Index("IX_FirstAndSecond", 2, IsUnique = true)]
public int SecondColumn { get; set; }
Upvotes: 1