Chapter 12. Saving data with Entity Framework Core

 

This chapter includes

  • What Entity Framework Core is and why you should use it
  • Adding Entity Framework Core to an ASP.NET Core application
  • Building a data model and using it to create a database
  • Querying, creating, and updating data using Entity Framework Core

Most applications that you’ll build with ASP.NET Core will require storing and loading some kind of data. Even the examples so far in this book have assumed you have some sort of data store—storing exchange rates, user shopping carts, or the locations of physical main street stores. I’ve glossed over this for the most part but, typically, you’ll store this data in a database.

Working with databases can often be a rather cumbersome process. You have to manage connections to the database, translate data from your application to a format the database can understand, as well as hande a plethora of other subtle issues.

You can manage this complexity in a variety of ways, but I’m going to focus on using a new library built for .NET Core: Entity Framework Core (EF Core). EF Core is a library that lets you quickly and easily build database access code for your ASP.NET Core applications. It’s modeled on the popular Entity Framework 6.x library, but has significant changes that mean it stands alone in its own right and is more than an upgrade.

12.1. Introducing Entity Framework Core

12.2. Adding EF Core to an application

12.3. Managing changes with migrations

12.4. Querying data from and saving data to the database

12.5. Using EF Core in production applications

Summary

sitemap