1 Introduction to Entity FrameworkCore


This chapter covers

  • Understanding the anatomy of an EF Core application
  • Accessing and updating a database with EF Core
  • Exploring a real-world EF Core application
  • Deciding whether to use EF Core in your application

Entity Framework Core, or EF Core, is a library that allows software developers to access databases. There are many ways to build such a library, but EF Core is designed as an object-relational mapper (O/RM). O/RMs work by mapping between the two worlds: the relational database with its own API, and the object-oriented software world of classes and software code. EF Core’s main strength is allowing software developers to write database access code quickly.

EF Core, which Microsoft released in 2016, is multiplatform-capable: it can run on Windows, Linux, and Apple. It does this as part of the .NET Core initiative, hence the Core part of the EF Core name. (But EF Core can be used with the existing .NET Framework too—see the note in section 1.10.5.) EF Core, ASP.NET Core (a web server-side application), and .NET Core are also all open source, each with an active issues page for interacting with development teams.

1.1 What you’ll learn from this book

1.2 My “lightbulb moment” with Entity Framework

1.3 Some words for existing EF6.x developers

1.4 An overview of EF Core

1.4.1 The downsides of O/RMs

1.5 What about NoSQL?

1.6 Your first EF Core application

1.6.1 What you need to install

1.6.2 Creating your own .NET Core console app with EF Core

1.7 The database that MyFirstEfCoreApp will access

1.8 Setting up the MyFirstEfCoreApp application

The classes that map to the database—Book and Author

1.8.2 The application’s DbContext

1.9 Looking under the hood of EF Core

1.9.1 Modeling the database

1.9.2 Reading data from the database

1.9.3 Updating the database

1.10 Should you use EF Core in your next project?

1.10.1 Latest generation

1.10.2 Multiplatform and open source

1.10.3 Rapid development

1.10.4 Well supported

1.10.5 Access to NuGet libraries

1.10.6 Fully featured O/RM

1.10.7 Stable library

1.10.8 Always high-performance

1.11 When should you not use EF Core?