Thursday, 19 September 2013

Unique Key constraints for multiple columns EF

Unique Key constraints for multiple columns EF

public class Entity
{
public string EntityId { get; set;}
public int FirstColumn { get; set;}
public int SecondColumn { get; set;}
}
I want to make the combination between FirstColumn and SecondColumn as
unique.
Example:
Id FirstColumn SecondColumn
1 1 1 = OK
2 2 1 = OK
3 3 3 = OK
5 3 1 = THIS OK
4 3 3 = GRRRRR! HERE ERROR
Is anyway to do that. Thanks!

No comments:

Post a Comment