Created
March 24, 2016 12:41
-
-
Save testfirstcoder/c93cc27d25e614b24f7e to your computer and use it in GitHub Desktop.
Entity Framework Fluent API - Unique key for multiple columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class PropertyConfigurationExtensions | |
{ | |
public static PrimitivePropertyConfiguration IsUnique(this PrimitivePropertyConfiguration configuration, | |
string indexName, int indexOrder) | |
{ | |
var indexAttribute = new IndexAttribute(indexName, indexOrder) | |
{ | |
IsUnique = true | |
}; | |
return configuration.HasColumnAnnotation(IndexAnnotation.AnnotationName, new IndexAnnotation(indexAttribute)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment