Reputation: 6680
I'm using MS SQL Server 2012 + the Entity Framework 6.1.1. I have created a model using the designer. Now, I would like to add a unique to an attribute. How can I achieve this using the designer / keep the model generation?
Edit: I do the model first approach
Thank you
Upvotes: 1
Views: 1813
Reputation: 5635
Read this! It should help you in the right direction...
The idea is to use code like this:
CreateIndex("dbo.Users","Username",true);
Which is a EF method. I don't think it's possible in the designer then...
EDIT
Found this post that states that unique constraints are possible (not in the designer, but in code) like this:
[Index(IsUnique = true)]
public string EmailAddress { get; set; }
Upvotes: 1