Skip to Content
Introducing .NET 4.0: with Visual Studio 2010
book

Introducing .NET 4.0: with Visual Studio 2010

by Alex Mackey
February 2010
Beginner content levelBeginner
400 pages
11h 13m
English
Apress
Content preview from Introducing .NET 4.0: with Visual Studio 2010

8.5. CRUD Operations in EF

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.

8.5.1. Creating

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET 3.5 For Dummies®

ASP.NET 3.5 For Dummies®

Ken Cox
ASP.NET 4 Unleashed

ASP.NET 4 Unleashed

Stephen Walther, Kevin Hoffman, Nate Dudek

Publisher Resources

ISBN: 9781430224556Purchase book