Is it possible using EF Fluent API to configure a Discriminator column and another string column to be part of a unique index constraint?
I have a list of identifiers, where the identifiers can be of different types. Each identifier has a property of type string which holds the identifying string.
A customer in my case can ha different identifiers. But there can only be one identifier with unique string per discriminator.
Abstract class defining a identifier type
 public abstract class CustomerIdentifier : Entity<int>
 {
    public string Identifier { get; set; }
 }
Concrete class derived from CustomerIdentifier
 class NationalIdNumberIdentifier : CustomerIdentifier
 {
 }
I've managed to configure index for the string column using the answer here, Unique Key constraints for multiple columns in Entity Framework as follows
class CustomerIdentifierMap : EntityTypeConfiguration<CustomerIdentifier>
{
    public CustomerIdentifierMap()
    {
        Property(p => p.Identifier).HasMaxLength(100).IsRequired().HasUniqueIndexAnnotation("UQ_IdentifierPerDiscriminator", 0);
    }
}
I need to somehow add another line here specifiying that the discrimnator should be included in the unique index constraint.
 
     
     
     
     
    