Is there any way to specify that an index should be unique using the Fluent API without adding it as a data annotation in the model itself?
public class RecordType
{
public int Id { get; set; }
[Index(IsUnique = true)]
public string RecordType { get; set; }
}
How can I add the unique index in the code below?
public class RecordTypeConfiguration : EntityTypeConfiguration<RecordType>
{
public RecordTypeConfiguration()
{
HasKey(i => i.Id);
Property(e => e.RecordType).HasColumnType("VARCHAR").HasMaxLength(1);
}
}