//Entity without StoredProcedures protected void Button1_Click(object sender, EventArgs e) { try { EMPDATA E = new EMPDATA(); E.EMPNO = int.Parse(txtEmployeeNo.Text); E.ENAME = txtEmployeeName.Text; E.JOB = txtJob.Text; E.MGR = int.Parse(txtMGR.Text); E.HIREDATE = DateTime.Parse(txtHireDate.Text); E.SAL = int.Parse(txtSalary.Text); E.COMM = int.Parse(txtCommission.Text); E.DEPTNO = int.Parse(txtDepartmentNo.Text); D.EMPDATAs.Add(E); D.SaveChanges(); } catch (DbUpdateException E1) { SqlException ex = E1.GetBaseException() as SqlException; if (ex.Message.Contains("EMP_PK")) { Label1.Text = "No Duplicate Empno"; } else if (ex.Message.Contains("FK__EMPDATA_DEPTNO")) { Label1.Text = "No Duplicate Deptno"; } else { Label1.Text = ex.Message; } } }