This question is locked. New answers and comments are not allowed.
I'm having trouble figuring out how to incorporate unique constraints into model validation. For example, I'm working on an interface that will allow admins to add new users to the database. I need to make sure that two users cannot have the same username.
The database (SQL Server) has a unique constraint on the username field. I used the Domain Model tool in OpenAccess to bring the database metadata into my project (ASP.NET MVC 4). I took a look at the xml behind the rlinq file and verified that the unique constraint was successfully brought into the project. I then created an MVC view through which admins can enter the info for new users, but when I tried to put in a duplicate username, instead of a validation error (which would allow me to gracefully inform the admin that the username is already taken), I get a SQL error.
What is the best way for me to generate a validation error based on a violation of the unique constraint? Is there an elegant solution that exists as part of OpenAccess?
Note: I believe I'm using the latest version of OpenAccess. I downloaded it last week.
The database (SQL Server) has a unique constraint on the username field. I used the Domain Model tool in OpenAccess to bring the database metadata into my project (ASP.NET MVC 4). I took a look at the xml behind the rlinq file and verified that the unique constraint was successfully brought into the project. I then created an MVC view through which admins can enter the info for new users, but when I tried to put in a duplicate username, instead of a validation error (which would allow me to gracefully inform the admin that the username is already taken), I get a SQL error.
What is the best way for me to generate a validation error based on a violation of the unique constraint? Is there an elegant solution that exists as part of OpenAccess?
Note: I believe I'm using the latest version of OpenAccess. I downloaded it last week.