What is DBSet in Entity Framework core 2026

DBSet:- A DBSet is a class that represents an Entity set in a database.
Note: DBSet allows to perform various database operations like
Querying
Inserting
Updating
Deleting

DBSet abstract class has many methods that will interact with database.Some of the methods are FindAsync,Add,SaveChanges,Remove etc LINQ queries against DBSet will be translated into queries against the database. for eg:-

using ( var context=new AppDbContext())
{
var user=new User{userid=1,username='shiva',Email='shiva@gmail.com}
//Add user
context.Users.Add(user);
context.SaveChanges();
//Remove user
context.Users.remove(user);
context.SaveChanges();
//Update User
context.Users.Update(user);
context.SaveChanges();
}
Entitiy:- Entity is a class that is mapped to database table.

You will remember that in AppDBContext class ,
public class AppDbContext :DbContext
{
public string ConnectionString{get;}
public DBSet<User> Users{get;set;}
public AppDbContext(){
ConnectionString="Data Source=(localdb)\\MSSqlLocalDB;Initial Catalog=EFCoreSampleDB;IntegratedSecurity=true"
}
public override onConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(ConnectionString)
}
}
public DBSet Users{get;set;} ,Here User class will be created as User table in Database. Here in the context of EntityFramework Core, this User class , Roles class are called Entities. if the classes are involved in database operations, we can call it as Entites class.
Note: Domain classes are called as entities when they are included in DBSet property.