public class HomeController : Controller { // GET: Home public ActionResult Index() { return View(); } [HttpPost] public ActionResult Index(Customer customer) { using (CustomerEntities entities = new CustomerEntities()) { entities.Customers.Add(customer); entities.SaveChanges(); int id = customer.CustomerId; } return View(customer); } }