Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Answer: (Skip, Take) Use .Skip() and .Take() for pagination: var page2 = context.Products .OrderBy(p => p.Id) .Skip(10) // Skip first 10 .Take(10) // Take next 10 .ToList(); What interviewers expect A clear defini…
Answer: Use FromSqlRaw() or FromSqlInterpolated(): var products = context.Products .FromSqlRaw("SELECT * FROM Products WHERE Price > {0}", 100) .ToList(); What interviewers expect A clear definition tied to EF Cor…
Answer: (FromSqlRaw, etc.) Use FromSqlRaw() or FromSqlInterpolated(): var products = context.Products .FromSqlRaw("SELECT * FROM Products WHERE Price > {0}", 100) .ToList(); What interviewers expect A clear defini…
Answer: Stored procedures can be called via raw SQL or FromSqlRaw: var orders = context.Orders .FromSqlRaw("EXEC GetOrdersByCustomer @CustomerId = {0}", customerId) .ToList(); For non-query SPs, use Database.ExecuteSqlRa…
Precompile frequently used queries to improve performance: private static readonly Func<MyDbContext, int, Product> _getProductById = EF.CompileQuery((MyDbContext ctx, int id) => ctx.Products.First(p => p.Id =…
Answer: Enable logging in DbContext options: optionsBuilder .UseSqlServer(connectionString) .LogTo(Console.WriteLine, LogLevel.Information); Or configure logging in ASP.NET Core logging pipeline. Repository Pattern &…
Generic repository provides CRUD for all entity types. Advantages: Reusable and reduces boilerplate. Simple for basic CRUD. Disadvantages: Can become too generic, losing flexibility for complex queries. May leak EF Core…
What are the trade-offs? Generic repository provides CRUD for all entity types. Advantages: Reusable and reduces boilerplate. Simple for basic CRUD. Disadvantages: Can become too generic, losing flexibility for complex q…
Answer: public interface IRepository&lt;T&gt; where T : class { Task&lt;T&gt; GetByIdAsync(int id); Task&lt;IEnumerable&lt;T&gt;&gt; GetAllAsync(); Task AddAsync(T entity); void Update(T e…
Sample signature / interface? public interface IRepository<T> where T : class Task<T> GetByIdAsync(int id); Task<IEnumerable<T>> GetAllAsync(); Task AddAsync(T entity); void Update(T entity); void…
public interface IUnitOfWork : IDisposable { IRepository<Customer> Customers { get; } IRepository<Order> Orders { get; } Task<int> CommitAsync(); } Implementation typically injects a single DbContext in…
Answer: wait _unitOfWork.CommitAsync(); wait transaction.CommitAsync(); } catch { wait transaction.RollbackAsync(); throw; } What interviewers expect A clear definition tied to EF Core in Entity Framework Core projects T…
Use DbContext transaction or IDbContextTransaction: using var transaction = await _context.Database.BeginTransactionAsync(); try // multiple repository operations await _unitOfWork.CommitAsync(); await transaction.Commit…
Mocking DbContext using frameworks like Moq (complex). Use InMemoryDatabase provider from EF Core for integration-like tests. Abstract dependencies and inject mocked interfaces for isolation. Performance, Best Practices,…
Answer: Properties not defined in your CLR classes but tracked by EF Core. Useful for storing metadata like CreatedBy, LastModified, or foreign keys without cluttering domain models. What interviewers expect A clear defi…
Answer: Practical use cases. Properties not defined in your CLR classes but tracked by EF Core. Useful for storing metadata like CreatedBy, LastModified, or foreign keys without cluttering domain models. What interviewer…
Answer: Use .AsNoTracking() for read-only queries. Avoid over-fetching: only select needed columns (Select). Use eager loading wisely (Include). Minimize round trips by batching operations. Use compiled queries for repea…
Answer: Use pagination (Skip, Take). Use streaming APIs like IAsyncEnumerable&lt;T&gt; with EF Core 5+. Avoid loading all data into memory at once. What interviewers expect A clear definition tied to EF Core in E…
Answer: EF Core doesn’t have built-in caching for query results. Use second-level caching libraries (like EFCoreSecondLevelCacheInterceptor). Use application-level caching (MemoryCache, Redis) strategically. What intervi…
Answer: Use FromSqlRaw or ExecuteSqlRaw to execute raw SQL. Map results to entities or DTOs. Use for performance-critical or legacy operations not easily expressed in LINQ. What interviewers expect A clear definition tie…
SQL Server, PostgreSQL, MySQL — differences, limitations? Providers abstract database-specific implementations. Each supports different features & SQL dialects. Some features may not be supported on all providers (e.…
Answer: Migrations support may be limited or unavailable. May require manual scripts or provider-specific tooling. Consider NoSQL-specific approaches for schema changes. What interviewers expect A clear definition tied t…
Answer: Use shadow properties or explicit properties for timestamps. Override SaveChanges() to set audit fields. Use global query filters for soft delete support. What interviewers expect A clear definition tied to EF Co…
Answer: EF Core can track foreign keys without them being defined in your model as properties. Useful for cleaner domain models. What interviewers expect A clear definition tied to EF Core in Entity Framework Core projec…
Answer: Configure relationships explicitly. HasOne / WithMany to define navigation properties and cardinality. Offers fine control beyond Data Annotations. What interviewers expect A clear definition tied to EF Core in E…
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: (Skip, Take) Use .Skip() and .Take() for pagination: var page2 = context.Products .OrderBy(p => p.Id) .Skip(10) // Skip first 10 .Take(10) // Take next 10 .ToList();
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Use FromSqlRaw() or FromSqlInterpolated(): var products = context.Products .FromSqlRaw("SELECT * FROM Products WHERE Price > {0}", 100) .ToList();
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: (FromSqlRaw, etc.) Use FromSqlRaw() or FromSqlInterpolated(): var products = context.Products .FromSqlRaw("SELECT * FROM Products WHERE Price > {0}", 100) .ToList();
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Stored procedures can be called via raw SQL or FromSqlRaw: var orders = context.Orders .FromSqlRaw("EXEC GetOrdersByCustomer @CustomerId = {0}", customerId) .ToList(); For non-query SPs, use Database.ExecuteSqlRaw().
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
private static readonly Func<MyDbContext, int, Product>
_getProductById =
EF.CompileQuery((MyDbContext ctx, int id) =>
ctx.Products.First(p => p.Id == id));
// Usage:
var product = _getProductById(context, 5);Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Enable logging in DbContext options: optionsBuilder .UseSqlServer(connectionString) .LogTo(Console.WriteLine, LogLevel.Information); Or configure logging in ASP.NET Core logging pipeline. Repository Pattern & Unit of Work
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Entity Framework Core Entity Framework Core Tutorial · EF Core
What are the trade-offs?
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: public interface IRepository<T> where T : class { Task<T> GetByIdAsync(int id); Task<IEnumerable<T>> GetAllAsync(); Task AddAsync(T entity); void Update(T entity); void Delete(T entity); Task SaveChangesAsync(); }
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Sample signature /
interface?
public interface IRepository<T> where T : class
Task<T> GetByIdAsync(int id);
Task<IEnumerable<T>> GetAllAsync();
Task AddAsync(T entity);
void Update(T entity);
void Delete(T entity);
Task SaveChangesAsync();
Entity Framework Core Entity Framework Core Tutorial · EF Core
public interface IUnitOfWork : IDisposable
{
IRepository<Customer> Customers { get; }
IRepository<Order> Orders { get; }
Task<int> CommitAsync();
}
repositories.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: wait _unitOfWork.CommitAsync(); wait transaction.CommitAsync(); } catch { wait transaction.RollbackAsync(); throw; }
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
using var transaction = await
_context.Database.BeginTransactionAsync();
try
// multiple repository operations
await _unitOfWork.CommitAsync();
await transaction.CommitAsync();
catch
await transaction.RollbackAsync();
throw;
Entity Framework Core Entity Framework Core Tutorial · EF Core
Performance, Best Practices, &
Advanced Features
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Properties not defined in your CLR classes but tracked by EF Core. Useful for storing metadata like CreatedBy, LastModified, or foreign keys without cluttering domain models.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Practical use cases. Properties not defined in your CLR classes but tracked by EF Core. Useful for storing metadata like CreatedBy, LastModified, or foreign keys without cluttering domain models.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Use .AsNoTracking() for read-only queries. Avoid over-fetching: only select needed columns (Select). Use eager loading wisely (Include). Minimize round trips by batching operations. Use compiled queries for repeated query patterns.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Use pagination (Skip, Take). Use streaming APIs like IAsyncEnumerable<T> with EF Core 5+. Avoid loading all data into memory at once.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: EF Core doesn’t have built-in caching for query results. Use second-level caching libraries (like EFCoreSecondLevelCacheInterceptor). Use application-level caching (MemoryCache, Redis) strategically.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Use FromSqlRaw or ExecuteSqlRaw to execute raw SQL. Map results to entities or DTOs. Use for performance-critical or legacy operations not easily expressed in LINQ.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
SQL Server, PostgreSQL, MySQL —
differences, limitations?
are provider-specific).
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Migrations support may be limited or unavailable. May require manual scripts or provider-specific tooling. Consider NoSQL-specific approaches for schema changes.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Use shadow properties or explicit properties for timestamps. Override SaveChanges() to set audit fields. Use global query filters for soft delete support.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: EF Core can track foreign keys without them being defined in your model as properties. Useful for cleaner domain models.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Entity Framework Core Entity Framework Core Tutorial · EF Core
Answer: Configure relationships explicitly. HasOne / WithMany to define navigation properties and cardinality. Offers fine control beyond Data Annotations.
In a production Entity Framework Core application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.