Entity Framework Core Flashcards
6 cards from real ASP.NET Core practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Entity Framework Core flashcards as text
What class is the primary entry point for Entity Framework Core database operations?
Answer: DbContext
DbContext manages entity objects during runtime, including querying, tracking, and saving changes to the database.
Which method saves all pending changes in the EF Core DbContext to the database?
Answer: SaveChangesAsync()
SaveChangesAsync() generates and executes the SQL INSERT/UPDATE/DELETE statements for all tracked entity changes.
What does DbSet represent in Entity Framework Core?
Answer: A collection of all entities of a given type that can be queried and saved
DbSet maps to a database table and provides LINQ query methods for querying and manipulating that entity type.
Which EF Core method retrieves an entity by its primary key from the DbContext?
Answer: FindAsync()
FindAsync() checks the local cache first before querying the database, returning null if not found.
What is a migration in Entity Framework Core?
Answer: A set of code files that record schema changes and can be applied to update the database
Migrations capture the difference between the current model and the last migration, generating Up() and Down() methods for schema changes.
Which CLI command creates a new EF Core migration?
Answer: dotnet ef migrations add
dotnet ef migrations add generates a new migration file based on changes detected between the model and existing migrations.