Is there a way to create an index on a property/column using code-first, instead of using the new IndexAttribute ?
From EF 6.1 onward the attribute [Index]
is supported.
Use [Index(IsUnique = true)]
for unique index.
Here is the link from Microsoft
public class User
{
public int UserId { get; set; }
[Index(IsUnique = true)]
[StringLength(200)]
public string Username { get; set; }
public string DisplayName { get; set; }
}