Created
February 26, 2015 05:14
-
-
Save jahands/72c19c12f2b490cdc837 to your computer and use it in GitHub Desktop.
EF Code-first IsUnique()
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
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel.DataAnnotations.Schema; | |
using System.Data.Entity.Infrastructure.Annotations; | |
using System.Data.Entity.ModelConfiguration.Configuration; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Imflow.Data | |
{ | |
public static class MappingExtensions | |
{ | |
public static PrimitivePropertyConfiguration IsUnique(this PrimitivePropertyConfiguration configuration) | |
{ | |
return configuration.HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute { IsUnique = true })); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment