A
A
aydep2022-03-09 21:11:44
Entity Framework
aydep, 2022-03-09 21:11:44

How to make a field, besides ID, unique?

Actually how to make any field unique.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
oleg_ods, 2022-03-09
@aydep

In the OnModelCreating method
modelBuilder.Entity().HasIndex(x => x.YourProp).IsUnique();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question