How can one set some attribute in Entity (Entity Framework) to be unique? One possibility would be to make it primary key but that's not what I want.
You can avoid duplicate values by setting an index property to yes and u can do this by right clicking a particular entity and click edit entity and set the index property to yes.
Entity framework doesn't support unique keys so the only way is to set the unique constraint / index in the database. It will not ensure uniqueness in the application when you try to insert / update records but the exception will be fired if you try to save non unique value to the database.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With