Working with EF Core
EF Core is an ORM that is recommended for any ASP.NET Core 5 application that uses a relational database as the data store. Earlier, we saw how in ADO.NET, we must create Connection
, Command
, and Reader
objects. EF simplifies this process by providing an abstraction and allowing developers to write application code, and like any other ORM, EF helps in performing various operations on databases using the object model paradigm.
Configuring EF Core is as simple as installing the required NuGet packages, injecting the required services in the Startup
class, and then using them wherever required. As part of this process, one of the key classes that needs to be defined is the database context, and that needs to inherit the Microsoft.EntityFrameworkCore.DbContext
class. Let's see how we do that along with the remaining EF Core configuration.
Configuration and querying
The DbContext
class in EF Core holds all the required abstraction for our application...