Skip to content

Instantly share code, notes, and snippets.

@msiddiqi
Created March 29, 2012 02:47
Show Gist options
  • Save msiddiqi/2232722 to your computer and use it in GitHub Desktop.
Save msiddiqi/2232722 to your computer and use it in GitHub Desktop.
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