From EF6.1, we have a way of specifying a clustered index on a property
public class Person
{
[Index(IsClustered = true, IsUnique = true)]
public long U
For EF Core 3.0+ You can now use IsClustered:
modelBuilder.Entity()
.HasIndex(e => e.UserName)
.IsUnique()
.IsClustered();
.ForSqlServerIsClustered() is now marked as obsolete.
Also be aware that if you have a Primary Key on the table you may also need to explicitly remove the clustering on it before you add the clustering on your Username:
modelBuilder.Entity()
.HasKey(e => e.PersonId)
.IsClustered(false);
modelBuilder.Entity()
.HasIndex(e => e.UserName)
.IsUnique()
.IsClustered();