DbContext
is simply the way for the developers to incorporate Entity Framework based data to the application.ObjectContext
class, but now in the latest version, we have DbContext
class.DbContext
in Entity Framework Core consist of the following features and responsibilities:DbContext
allows the user to manage the complete database. It allows the user to create, delete or check for the existing database connections inside the given project.DbContext
also allows the user to check, establish and close the connections between the databases as per the requirement of the project.DbContext
represents all the entities in a project, it also manages these entities throughout their lifetime. It also applies CRUD operations on all the entity types, such as Add
, Attach
or Remove
.DbContext
also converts the LINQ queries to the SQL queries using the querying method.DbContext
includes the Change Tracker API which tracks all the changes when entities are added, updated or deleted.DbContext
performs all the CRUD related operations, It persists all the changes made to the database.DbContext
keeps all the changes made to the entities throughout their lifetime in the form of first-level cache files.DbContext
also performs model binding operations in which it automatically read classes and code-based configuration to build an in-memory model, metadata and database.DbContext
converts the queries from the database tables into entities.DbContext
configures the behavior of the context of the databases.DbContext
checks the validity of the data and performs automatic validation of the data.DbContext
in Entity Framework Core, there are three types of query operations which can be performed, they are:DbContext
, the developer must prepare the relevant code related to the database.SaveChanges
method insert all entities to the database.DbContext
in order to check its state and change it to Deleted.DbContext.Remove
method, after applying this code, the DbContext
usually executes two SQL Statements.