Guys,
How to solve the index name conflict in EF
A
B - Has index named abc
C
D - Has index named abc
E - change named abc - abc1
Guys,
How to solve the index name conflict in EF
A
B - Has index named abc
C
D - Has index named abc
E - change named abc - abc1
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Jan 29, 2023, 12:31 PM EST
Hi,
To resolve index name conflict is by using attribute [Index(IsUnique = true, Name = "Index_Name")] on the property of the entity class.
public class A { [Index(IsUnique = true, Name = "A_abc")] public int SomeProperty {get; set;} } public class B { [Index(IsUnique = true, Name = "B_abc")] public int SomeProperty {get; set;} }This way, you are specifying the Index name on the property level, which would resolve the conflict.
Reference Link:
https://learn.microsoft.com/en-us/ef/core/modeling/indexes?tabs=data-annotations