LearnThatStack Ace your next interview
Backend Development

Entity Framework Core.

Start free Change topic Change
Practice · Questions

All questions

Showing of 52
Beginner 12
01

What are the main approaches to using Entity Framework Core?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

EF Core supports three main approaches:

  1. Code First: Define entity classes first, then generate database schema
    • Start with C# classes (entities)
    • Use migrations to create and update database
    • Good for new projects with full control over data model
  2. Database First: Start with existing database, generate entity classes
    • Use Scaffold-DbContext command
    • Generates DbContext and entity classes from existing database
    • Good for existing databases or database-driven development
  3. Model First: Design model using visual designer (less common in EF Core)
    • Primarily supported through external tools
    • Not as prominent as in EF6
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

What is an Entity in Entity Framework Core?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

An Entity is a class that represents a table in the database. Each instance of an entity corresponds to a row in the table.

public class Product
{
    public int Id { get; set; }           // Primary key
    public string Name { get; set; }
    public decimal Price { get; set; }
    public int CategoryId { get; set; }
    // Navigation property
    public Category Category { get; set; }
}

Requirements for an entity:

  • Must be a reference type (class)
  • Must have a parameterless constructor
  • Should have a primary key property
  • Properties must have public getters and setters (or protected setters)
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What is DbContext and what is its role in Entity Framework Core?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

DbContext is the primary class responsible for interacting with the database. It represents a session with the database and acts as a Unit of Work pattern implementation.
Key responsibilities:

  • Database connection management: Manages database connections
  • Change tracking: Tracks changes to entities
  • Query execution: Translates LINQ queries to SQL
  • Transaction management: Handles database transactions
  • Entity lifecycle: Manages entity states (Added, Modified, Deleted, etc.)
public class ApplicationDbContext : DbContext
{
    public DbSet<Product> Products { get; set; }
    public DbSet<Category> Categories { get; set; }
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseSqlServer("connection-string");
    }
}
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

What is DbSet and how is it used?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

DbSet<T> represents a collection of entities of a specific type that can be queried from the database. It provides an abstraction over database tables.
Key features:

  • Querying: Supports LINQ queries
  • CRUD operations: Add, Remove, Update operations
  • Change tracking: Tracks entity states
  • Local view: Access to locally tracked entities
// Querying
var products = context.Products.Where(p => p.Price > 100).ToList();
// Adding
context.Products.Add(new Product { Name = "New Product" });
// Removing
context.Products.Remove(product);
// Local entities
var localProducts = context.Products.Local.ToList();
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

What is the difference between DbContext.SaveChanges() and DbContext.SaveChangesAsync()?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain
  • SaveChanges(): Synchronous method that blocks the calling thread until database operations complete
  • SaveChangesAsync(): Asynchronous method that doesn't block the calling thread, returns Task<int>
// Synchronous
int changesCount = context.SaveChanges();
// Asynchronous
int changesCount = await context.SaveChangesAsync();

Benefits of async:

  • Better scalability in web applications
  • Doesn't block threads during I/O operations
  • Improves application responsiveness
  • Essential for high-traffic applications
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

What are Data Annotations and how are they used in Entity Framework Core?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Data Annotations are attributes applied to entity classes and properties to configure the model and validation rules.
Common annotations:

public class Product
{
    [Key]
    public int ProductId { get; set; }
    [Required]
    [MaxLength(100)]
    public string Name { get; set; }
    [Column(TypeName = "decimal(18,2)")]
    public decimal Price { get; set; }
    [ForeignKey("CategoryId")]
    public Category Category { get; set; }
    [NotMapped]
    public string DisplayName { get; set; }
}

Categories:

  • Key attributes: [Key], [DatabaseGenerated]
  • Validation: [Required], [MaxLength], [Range]
  • Schema: [Table], [Column], [NotMapped]
  • Relationships: [ForeignKey], [InverseProperty]
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

What are Migrations in Entity Framework Core and why are they important?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Migrations are a way to incrementally update the database schema to keep it in sync with the entity model while preserving existing data.
Benefits:

  • Version control: Track database schema changes
  • Team collaboration: Share schema changes across team
  • Deployment: Apply changes to different environments
  • Rollback: Undo changes if needed
  • Data preservation: Update schema without losing data
# Add migration
dotnet ef migrations add InitialCreate
# Update database
dotnet ef database update
# Remove last migration
dotnet ef migrations remove
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

08

How do you create and apply migrations?

Part of Pro
09

What are the different types of relationships in Entity Framework Core?

Part of Pro
10

How do you configure One-to-Many relationships?

Part of Pro
11

What are Navigation Properties and how do they work?

Part of Pro
12

What is the difference between First(), FirstOrDefault(), Single(), and SingleOrDefault()?

Part of Pro
Intermediate 21
13

Explain the different ways to configure DbContext.

Part of Pro
14

What is Fluent API and when would you use it over Data Annotations?

Part of Pro
15

How do you scaffold an existing database using Entity Framework Core?

Part of Pro
16

How can you customize migration generation?

Part of Pro
17

What happens when you have migration conflicts in a team environment?

Part of Pro
18

How do you configure Many-to-Many relationships in EF Core 5+?

Part of Pro
19

How do you handle self-referencing relationships?

Part of Pro
20

What's the difference between IQueryable and IEnumerable in EF Core context?

Part of Pro
21

How do you use Include() for eager loading and what are its limitations?

Part of Pro
22

How do you write raw SQL queries in Entity Framework Core?

Part of Pro
23

What is Change Tracking in Entity Framework Core and how does it work?

Part of Pro
24

How do you disable Change Tracking for read-only scenarios?

Part of Pro
25

What is the difference between Update() and modifying properties directly?

Part of Pro
26

How do you detect property changes in Entity Framework Core?

Part of Pro
27

How do you configure entity properties using Fluent API?

Part of Pro
28

How do you configure indexes in Entity Framework Core?

Part of Pro
29

How do you implement paging efficiently in Entity Framework Core?

Part of Pro
30

How do you work with database transactions in Entity Framework Core?

Part of Pro
31

How do you handle the "Cannot access a disposed object" error?

Part of Pro
32

How do you implement Repository Pattern with Entity Framework Core?

Part of Pro
33

How do you implement database seeding in Entity Framework Core?

Part of Pro
Expert 19
34

What are Global Query Filters and how do you implement them?

Part of Pro
35

What are Value Converters and how do you use them?

Part of Pro
36

What are some common performance issues in Entity Framework Core and how to avoid them?

Part of Pro
37

What is Compiled Queries and when should you use them?

Part of Pro
38

How do you use Split Queries to optimize performance?

Part of Pro
39

How do you handle concurrency conflicts in Entity Framework Core?

Part of Pro
40

What is the difference between pessimistic and optimistic locking?

Part of Pro
41

What are Owned Types and when would you use them?

Part of Pro
42

How do you implement Table Splitting in Entity Framework Core?

Part of Pro
43

What are Shadow Properties and how do you use them?

Part of Pro
44

How do you implement Soft Delete using Global Query Filters?

Part of Pro
45

What are Keyless Entity Types and when would you use them?

Part of Pro
46

What are some Entity Framework Core best practices for production applications?

Part of Pro
47

What are the common causes of poor performance in EF Core applications?

Part of Pro
48

How do you handle complex business logic with Entity Framework Core?

Part of Pro
49

What are some strategies for testing applications that use Entity Framework Core?

Part of Pro
50

How do you implement multi-tenancy with Entity Framework Core?

Part of Pro
51

How do you implement temporal tables (system-versioned tables) with EF Core?

Part of Pro
52

How do you handle complex inheritance scenarios in Entity Framework Core?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Entity Framework Core? Send them this set.
Pro · $10/mo

45 of 52 Entity Framework Core answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git