Entity Framework Core Interview Question #2
What is an ORM and why is it useful?
EF Core Fundamentals & DbContext Junior Beginner
Quick Interview Answer
An ORM, or Object-Relational Mapper, maps application objects to relational database structures. It reduces repetitive code for reading rows, converting them into objects, tracking changes, and generating INSERT, UPDATE, DELETE, and SELECT operations.
Detailed Explanation
An ORM, or Object-Relational Mapper, maps application objects to relational database structures. It reduces repetitive code for reading rows, converting them into objects, tracking changes, and generating INSERT, UPDATE, DELETE, and SELECT operations.
The main benefits are developer productivity, strongly typed queries, centralized mapping, and easier integration with domain or application models. However, an ORM can still generate inefficient SQL if queries are poorly designed.
A strong EF Core developer treats the ORM as an abstraction over the database, not as a replacement for database knowledge.
Code Example
var activeProducts = await db.Products
.Where(p => p.IsActive)
.OrderBy(p => p.Name)
.ToListAsync();