Top 50 Entity Framework / EF Core Interview Questions π
Introduction
Entity Framework (EF) and Entity Framework Core (EF Core) are Microsoft’s ORM frameworks that simplify data access in .NET applications. EF6 is mature and feature-rich, while EF Core is lightweight, cross-platform, and modern. Interviewers often test candidates on their understanding of EF/EF Core fundamentals, LINQ, migrations, performance optimization, and advanced scenarios. This blog organizes the Top 50 Interview Questions into structured sections for easy preparation.
1. Basics
What is Entity Framework and why is it used?
Difference between EF6 and EF Core?
What are DbContext and DbSet?
Explain Code First vs Database First approaches.
What is the difference between lazy loading, eager loading, and explicit loading?
How does EF handle relationships (one-to-one, one-to-many, many-to-many)?
What is the difference between tracked and untracked entities?
Explain the role of the change tracker.
What are navigation properties?
How does EF Core support multiple database providers?
2. LINQ
What is LINQ to Entities?
Difference between LINQ to Objects and LINQ to Entities?
How does EF Core translate LINQ queries into SQL?
What is deferred execution in LINQ?
Explain client-side vs server-side evaluation in EF Core.
How do you perform joins in LINQ with EF?
What are projection queries?
How do you use GroupBy in EF Core?
What is the difference between Single, First, and Find methods?
How do you write raw SQL queries in EF Core?
3. Migrations
What are migrations in EF Core?
How do you create and apply migrations?
Difference between
Add-MigrationandUpdate-Databasecommands?How do you revert a migration?
How does EF Core handle schema changes?
What is the purpose of the
__EFMigrationsHistorytable?How do you seed data using migrations?
How do you apply migrations in production?
What is the difference between automatic and manual migrations?
How do you handle migration conflicts in team environments?
4. Performance
How do you optimize EF Core queries?
What is query splitting in EF Core?
How does EF Core handle caching?
What is compiled query in EF Core?
How do you reduce memory leaks in EF applications?
Difference between AsNoTracking and tracked queries?
How do you use batch updates and deletes in EF Core?
What is the impact of lazy loading on performance?
How do you optimize loading related data?
How do you profile EF Core queries?
5. Advanced Scenarios
How do you implement concurrency control in EF Core?
What are shadow properties in EF Core?
How do you configure composite keys?
What is value conversion in EF Core?
How do you implement soft deletes?
How do you use temporal tables in EF Core?
How does EF Core support JSON columns?
How do you handle disconnected entities in EF Core?
How do you implement auditing with EF Core?
How do you extend EF Core with custom conventions?
Conclusion
These 50 questions cover the breadth of EF and EF Core knowledge expected from experienced developers. From basics and LINQ to migrations, performance optimization, and advanced scenarios, this list serves as a comprehensive guide for interview preparation. By mastering these topics and preparing answers with real-world examples, you’ll be ready to tackle interviews confidently.
This was part of Interview Preparation With Bipin — Let’s Crack It!
Comments
Post a Comment