Skip to content

Instantly share code, notes, and snippets.

@divega divega/ef6.2-issue274.cs
Last active May 23, 2017

Embed
What would you like to do?
Pattern for configuring indexes in EF6.2
using System;
using System.Data.Entity;
namespace MyApplication
public class MyContext: DbContext
{
public DbSet<Person> People { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Person>().Property(p => p.Name).HasMaxLength(100);
modelBuilder.Entity<Person>().HasIndex(p => p.Name).IsUnique();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.