I\'m using Entity Framework 6.1 code-first and my domain model is below.
class Item
{
[Index]
public string CreatedBy { set; get; }
}
If you use EntityTypeConfiguration aka mappings :
public class MyPocoEntitiyTypeConfig : EntityTypeConfiguration where T:class
{
}
public class MyPocoEnt
{
public virtual string MyProp { get; set; }
}
public class MyPocoEntMapping : MyPocoEntitiyTypeConfig
{
public MyPocoEntMapping()
{
Property(x => x.MyProp).HasMaxLength(300);
Property(x => x.MyProp).HasColumnAnnotation("Index", new IndexAnnotation(new IndexAttribute("MyProp") { IsUnique = true }));
}
}
}