Created
March 29, 2012 02:47
-
-
Save msiddiqi/2232722 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var context = new InstituteEntities()) | |
{ | |
var student = context.Students.Create(); | |
student.StudentFirstName = "Muhammad"; | |
student.StudentLastName = "Siddiqi"; | |
context.Students.Add(student); | |
try | |
{ | |
//save changes | |
context.SaveChanges(); | |
} | |
catch (DbEntityValidationException validationException) | |
{ | |
string validationErrorMessage = | |
DbEntityValidationMessageParser.GetErrorMessage(validationException); | |
Console.WriteLine(validationErrorMessage); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment