โ† All ASP.NET Core Flashcard Decks

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
  1. What does AsNoTracking() do in an EF Core LINQ query?

    Answer: Returns entities without adding them to the change tracker, improving read performance

    AsNoTracking() skips the overhead of the change tracker for read-only scenarios, reducing memory and CPU usage.

  2. Which EF Core method applies pending migrations to the database?

    Answer: dotnet ef database update

    dotnet ef database update applies all pending migrations, creating or altering tables as defined in the migration files.

  3. What is the purpose of the Fluent API in Entity Framework Core?

    Answer: To configure entity mappings and relationships in OnModelCreating using method chaining

    The Fluent API in OnModelCreating() allows detailed configuration of columns, keys, indexes, and relationships beyond data annotations.

  4. Which EF Core loading strategy fetches related entities in the same query using a JOIN?

    Answer: Eager loading with Include()

    Eager loading via Include() fetches related entities in a single SQL query using JOINs, avoiding the N+1 query problem.

  5. What does the [Key] attribute do on an entity property in EF Core?

    Answer: Designates the property as the primary key for the entity

    [Key] overrides EF Core's convention of using 'Id' or '{TypeName}Id' as the primary key, explicitly designating the property.

  6. Which EF Core query returns only the first matching entity or null if not found?

    Answer: FirstOrDefaultAsync()

    FirstOrDefaultAsync() returns the first matching entity or null without throwing, while FirstAsync() throws if no match exists.