Chapter 2. Data access reloaded: Entity Framework

 

This chapter covers

  • Designing an application
  • Understanding an ORM
  • Learning Entity Framework
  • Reading and updating data with Entity Framework

When databases are in place, accessing data becomes a key concern. The way you communicate with the database and, more importantly, the way you represent data inside your application becomes one thing that can shift your application from one that works to a real success.

You have a lot of options. The first option is to use ADO.NET objects, like connections, adapters, readers, and datasets. This approach is easy to understand and enables you to immediately start writing code.

Another option is to use ADO.NET classes to interact with the database and then create your own classes (object model) to represent data inside the application. The initial learning curve with such a pattern is higher compared with the previous one, but in the long run, this pattern ensures higher maintainability.

The last option is to use an ORM tool, which hides the complexity of using ADO.NET classes and lets you work only with objects in your application. An ORM tool includes the best of the previous approaches because it offers immediate and sustained productivity. Microsoft has developed an ORM whose name is Entity Framework.

2.1. Designing an application

2.2. Using an ORM to build a data layer

2.3. Introducing Entity Framework

2.4. Summary