I've got a simple form with 3 text boxes and and a button. All I want to do is send the data in the form to my database. In my database I have a table called contacts with three columns (ID-Primary Key,fname,lname,phone) I've created an Ado.net Entity framework model and called it Contacts.
This is the code I've got so far:
protected void Button1_Click(object sender, EventArgs e)
{
Contact con = new Contact();
con.fname = TextBox1.Text;
con.sname = TextBox2.Text;
con.phone = TextBox3.ToString();
ContactDb db = new ContactDb();
db.Contacts.Add(con);
db.SaveChanges();
}
When I click ok this error comes up:Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.