I have a column in a table, that is the name of a store, for example, and it should remain unique. I have added the unique constraint to the table.
I was about to add some code to my save method, which does a check for a duplicate, before attempting the same, but ... is there any reason NOT to just do the same, make the unique constraint catch the issue, and then somehow (with entity framework), check the error, and reply with the appropriate reply?
That would save a 'SELECT'... but is it good practice to remove 'business logic' from the code, and allow the database to report such a breech?
And can I just, from the SaveChanges() command sent to Entity Framework, what the error was?