public void InsertForm() { using (VaranegarEntities db = new VaranegarEntities()) { string new_filename = string.Empty; if (fuImage.PostedFile.ContentLength != 0) { string original_filename = Path.GetFileName(fuImage.PostedFile.FileName); new_filename = Guid.NewGuid().ToString() + Path.GetExtension(original_filename); string new_filepath = Server.MapPath("~/Uploads/Gallery/" + new_filename); fuImage.PostedFile.SaveAs(new_filepath); ViewState["GImage"] = new_filename; } GalleryGroups pg = new GalleryGroups(); pg.Id = Guid.NewGuid(); pg.ImageUrl = new_filename; pg.Title = txtTitle.Text; pg.Priority = Convert.ToInt32(txtPri.Text); pg.IsDelete = false; db.GalleryGroups.Add(pg); db.SaveChanges(); } }