liveBook · Manning

DbSet<T>

As explained in .NET in Action, Second Edition

DbSet is an Entity Framework Core API type representing a queryable and persistable collection of entities in a database context.

DbSet<T> represents a collection of Entity Framework Core entities attached to a DbContext. An entity can correspond to a table or another database object, such as a view. section 5.2

Declaring and using a DbSet

Declare a typed property such as public DbSet<Book> Books { get; set; }. Add Book objects through the context, call SaveChanges, then query Books and order the results by Id. EF Core populates generated identifiers for saved records.

How .NET in Action, Second Edition covers it

How deep it goes
Explains declaration, querying, saving, generated identifiers, and version-specific initialization warnings.
Examples
Uses a Book entity, an in-memory database, inserted catalog books, SaveChanges, and an ordered Books query.
What it assumes
Assumes familiarity with C# classes and properties while demonstrating DbContext integration from the initial application setup.
What you can do after
Operate a DbSet<T> by declaring it on a DbContext, adding entities, saving changes, and querying results.
How it connects
Connects DbSet<T> to DbContext, entities, database tables, database views, SaveChanges, and primary keys.

Also explained in

Compare how 3 books explain DbSet<T> →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of .NET in Action, Second Edition. The section links point to the parts of the book it draws on.