February 2010
Beginner
400 pages
11h 13m
English
When you utilize EF, a connection to a database called an object context is created. When new entities are created or properties change, they are not written back to the database immediately; rather, a flag is set on the entity to indicate that it has changed, but not saved to the database (a dirty state). Changes are then saved back to the database when the SaveChanges() method is called on the object context.
The following example shows how to create a new Film entity with a related FilmShowing entity and save the new items back to the database:
BookEntities ctx = new BookEntities(); Film NewFilm = new Film(); NewFilm.Title = "New film"; NewFilm.Description = "New film"; NewFilm.Length = 300; FilmShowing ...