protected void Application_Start() { AreaRegistration.RegisterAllAreas(); // Use LocalDB for Entity Framework by default Database.DefaultConnectionFactory = new SqlConnectionFactory(@"Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True"); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); using (var context = new EntitySplittingEntities()) { var person = new Person { FirstName = "Irina", LastName = "Doe", Email = "*****@*****.**", Phone = "555-555-5555" }; context.People.Add(person); context.SaveChanges(); foreach (var item in context.People) { Console.WriteLine(item.FirstName); } } }
public ActionResult Edit(Person person) { if (ModelState.IsValid) { db.Entry(person).State = EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(person); }
public ActionResult Create(Person person) { if (ModelState.IsValid) { db.People.Add(person); db.SaveChanges(); return RedirectToAction("Index"); } return View(person); }