Index Attribute:

Entity Framework 6 provides the [Index] attribute to create an index on a particular column in the database, as shown below:

class Student
    public int Student_ID { get; set; }
    public string StudentName { get; set; }
    public int RegistrationNumber { get; set; }

By default, the index name will be IX_{property name}. However, you can change the index name.

You can also make it a clustered index by specifying IsClustered = true or create a unique index by specifying IsUnique=true.

[Index( "INDEX_REGNUM", IsClustered=true, IsUnique=true )]
public int RegistrationNumber { get; set; }

Test Your Entity Framework Knowledge: