I want to enforce Unique constraint in a table & I am using Entity Framework Code-First.
Is it possible to add a unique constraint using EF 6 as i believe in earlier versions it was not possible.
I want to enforce Unique constraint in a table & I am using Entity Framework Code-First.
Is it possible to add a unique constraint using EF 6 as i believe in earlier versions it was not possible.
Let's say that you want to add the Unique constraint on only one attribute, you can do as following, starting from EF6.1
If you have multiple fields that are related to the same index then you are going to use
Please refer to this link for further informations
It appears that the unique constraint feature that was scheduled to release with Version 6 got pushed to 6.1.
With EF 6.1, you can define a constraint using the Index attribute as shown below:
OR
You can use Fluent API as shown here in MSDN