I am using ASP.Net with ADO.Net Entity Data Model. I use this for add record:
userEntity.AddToUSERs(newUser);
In this case, can ADO.Net Entity Data Model validate unique user and display error message?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No. Entity Framework does not handle Unique Keys. You have to manually handle these cases.
One possible solution would be to catch the exception when
SaveChangesis called and check the message of theExceptionand extract which unique key is violated and then using that add aModelStateerror with the relevant property name.