public bool AddProduct(Product displayP) { hasError = false; try { SqlProduct p = new SqlProduct(displayP); int? newProductId = 0; ContactDBEntities3 db = new ContactDBEntities3(); Contact e = new Contact() {FirstName = p.FirstName,LastName=p.LastName , EmailID = p.EmailID, State = p.State, City = p.City,PhNo=p.PhNo }; // e.Vacations.Add(v); db.Contacts.Add(e); db.SaveChanges(); p.ContactID =1; displayP.ProductAdded2DB(p); //update corresponding Product ProductId using SqlProduct } catch (Exception ex) { errorMessage = "Add error, " + ex.Message; hasError = true; } return !hasError; }