Gibt es eine Möglichkeit, einen Kompost-Unique-Index in Fluente Api basierend auf einem bestimmten Wert zu erstellen?Entity Fluent API - Kompost Unique Index
Ex:
string code { get; set; }
bool active { get; set; }
Property(x => x.code)
.HasMaxLength(6)
.HasColumnAnnotation(
IndexAnnotation.AnnotationName,
new IndexAnnotation(new IndexAttribute("IX_CODE", 1) { IsUnique = true }))
.IsRequired();
Property(x => x.active)
//I want this only if "active == true"
.HasColumnAnnotation(
IndexAnnotation.AnnotationName,
new IndexAnnotation(new IndexAttribute("IX_CODE", 2) { IsUnique = true }))
.IsRequired();
Das ist nicht für mich arbeiten, weil ich meine „Code“ wollen nur eindeutig sein, wenn mein „aktiv“ wahr ist, sonst kann ich dupliziert Codes haben (mit aktiver == falsch).
Wer kennt einen Weg?