public IActionResult Create(Contact contact) { ModelState.Clear(); TryValidateModel(contact); if (ModelState.IsValid) { using (var db = new ContactsContext()) { db.Contacts.Add(contact); var count = db.SaveChanges(); return RedirectToAction("Index"); } } return View(contact); }
public HomeController() { _db = new ContactsContext(); }