📁 Sangam Dhakal - Portfolio v2.0 - Netscape Navigator 4.0
_
□
×

πŸ“š .NET Interview Questions

1325 questions for senior .NET engineer interviews, each with a 30-second answer, the full answer, a deep dive, the follow-ups interviewers ask next, and real-world production problems.

Phase 11 — Entity Framework Core

Entity Framework Core 10 from model to production: modelling and migrations, LINQ translation and loading strategies, change tracking, advanced mapping and concurrency, performance, and running EF Core safely in production on SQL Server.

  1. What are your options for bulk operations with EF Core? Explain ExecuteUpdate and ExecuteDelete, how SaveChanges batches AddRange, when you drop to SqlBulkCopy or a third-party library, and what skipping the change tracker means for interceptors, concurrency and in-memory state.

    Covers bulk data changes with EF Core 10: set-based ExecuteUpdateAsync/ExecuteDeleteAsync (EF Core 7+, delegate setters in EF Core 10), SaveChanges batching and MaxBatchSize for AddRange, SqlBulkCopy and table-valued parameters, third-party libraries and their licensing, and the consequences of bypassing the change tracker (stale tracked entities, no SaveChanges interceptors, no automatic concurrency checks, cascade and trigger behaviour).

    Mid-Level Theory Advanced EF Core Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  2. How do you see the SQL that EF Core generates and trace it back to the code that produced it? Explain ToQueryString, LogTo and ILogger categories, TagWith, the risks of EnableSensitiveDataLogging, and how EF Core queries show up in Application Insights or OpenTelemetry.

    Covers inspecting EF Core SQL: ToQueryString, simple logging with LogTo and event filters, the Microsoft.EntityFrameworkCore.Database.Command log category, query tags with TagWith and TagWithCallSite, EnableSensitiveDataLogging and EnableDetailedErrors and their privacy risks, dependency tracking in Application Insights and OpenTelemetry, and finding tagged queries in SQL Server.

    Intermediate Theory Advanced EF Core Β· πŸ”— 2 follow-ups
  3. Your API on Azure SQL throws intermittent SqlExceptions such as error 40613 during maintenance events. You turn on EnableRetryOnFailure, and now a checkout endpoint fails with an error saying the execution strategy does not support user-initiated transactions. How do you diagnose and fix it, and how do you keep retried work safe?

    Covers diagnosing transient Azure SQL failures with EF Core: transient error numbers and reconfiguration events, SqlServerRetryingExecutionStrategy and its defaults, the user-initiated transaction error and wrapping work in CreateExecutionStrategy().ExecuteAsync, idempotency and commit-in-doubt with ExecuteInTransactionAsync, connection resiliency in Microsoft.Data.SqlClient, and telemetry for retries.

    Senior Debugging Advanced EF Core Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  4. How would you make a set of split queries read a consistent snapshot of the data on SQL Server?
    Mid-Level Theory EF Core Performance
  5. When can a filtered index fail to be used by an EF Core query, and how do you make sure it is?
    Mid-Level Theory EF Core Performance
  6. How do you support a 'previous page' link with keyset pagination?
    Mid-Level Coding EF Core Performance
  7. How do you make a long-running bulk import restartable after a failure halfway through?
    Senior Theory EF Core Performance
  8. Your EF Core app's memory and CPU keep growing, and the query cache holds thousands of entries. What causes query cache pollution and how do you fix it?
    Senior Theory EF Core Performance
  9. Your API endpoint is slow and the logs show the same SELECT running 200 times for one request. What is the N+1 query problem in EF Core, how do you detect it (EF Core logging, Application Insights, MiniProfiler), and how do you fix it?

    Covers what N+1 queries are in EF Core, the code shapes that cause them, how to detect them with logging, Application Insights and MiniProfiler, and the fixes: projection, Include, batching by key and split queries.

    Mid-Level Debugging EF Core Performance Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  10. An EF Core query for 50 orders with three collection Includes takes seconds, and SQL Server reports hundreds of thousands of rows returned. Why does this happen, how do you confirm it is cartesian explosion, and how do you choose between projection, AsSplitQuery() and loading the collections separately?

    Covers why several collection Includes multiply rows in a single JOIN query, how to measure and confirm cartesian explosion (row counts, logical reads, the EF Core multiple-collection warning), and how to pick projection, split queries or separate loads.

    Mid-Level Theory EF Core Performance Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  11. What is over-fetching in EF Core, and how does client evaluation make it worse? Explain selecting only the columns you need, keeping large blobs out of hot queries, what happens when AsEnumerable() or ToList() appears in the middle of a query, and how you would find these problems.

    Covers column and row over-fetching in EF Core, large blob columns and table splitting, client evaluation through AsEnumerable or ToList in the middle of a query, and how to detect both in the generated SQL.

    Intermediate Theory EF Core Performance Β· πŸ”— 3 follow-ups
  12. How do you manage indexes from the EF Core side? Explain HasIndex and the [Index] attribute, unique, filtered and descending indexes and included columns on SQL Server, and which LINQ patterns stop SQL Server using an index even though the query translates.

    Covers declaring indexes in EF Core (HasIndex, [Index], IsUnique, HasFilter, IsDescending, IncludeProperties), how they reach SQL Server through migrations, and the non-sargable LINQ patterns (ToLower, Contains, date parts, implicit conversions) that defeat them.

    Mid-Level Theory EF Core Performance Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  13. Show how you would implement offset and keyset pagination in EF Core for an orders list sorted newest first. Why does Skip/Take get slower on deep pages, how do you build keyset paging on a composite key with a stable order, and what does the API contract look like?

    Covers the SQL and cost of Skip/Take offset paging, building keyset (seek) pagination on a composite (CreatedAt, Id) key in EF Core with a matching index, cursor tokens for the API, and when each approach fits.

    Mid-Level Coding EF Core Performance Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  14. You need to load 5 million rows nightly and update a million existing rows with EF Core on Azure SQL. How do you choose between SaveChanges batching, ExecuteUpdate, SqlBulkCopy and table-valued parameters? Cover batch size, transaction log and locking, and how you would measure the options.

    Covers large-scale writes from .NET to SQL Server: SaveChanges batching and MaxBatchSize, chunked ExecuteUpdate, SqlBulkCopy into staging tables with MERGE, table-valued parameters, transaction log, lock escalation and how to benchmark them.

    Senior Theory EF Core Performance Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  15. What is DbContext pooling in EF Core? Explain AddDbContextPool and AddPooledDbContextFactory, what EF Core resets when a context goes back to the pool and what it does not, how per-request state such as a tenant id can leak, and how much performance it really gains.

    Covers how EF Core DbContext pooling works, AddDbContextPool versus AddPooledDbContextFactory, what is reset on return, the constructor and state restrictions, safe per-request state through a factory, and how to measure the gain.

    Mid-Level Theory EF Core Performance Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  16. What are compiled queries and compiled models in EF Core, and what problem does each solve? Explain the per-query and start-up overhead they remove, EF.CompileAsyncQuery, dotnet ef dbcontext optimize, precompiled queries, the current state of Native AOT support, and when none of them is worth it.

    Covers where EF Core spends time outside SQL (query compilation and cache lookup, model building at start-up), compiled queries with EF.CompileAsyncQuery, compiled models with dotnet ef dbcontext optimize and MSBuild integration, precompiled queries and the experimental Native AOT support in EF Core 10.

    Senior Theory EF Core Performance Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  17. After a release, p95 latency on your orders API doubles and Azure SQL CPU climbs, but there are no errors. You suspect an EF Core query regression. Walk me through how you go from Application Insights to the SQL Server execution plan to the LINQ change that caused it, how you mitigate, and what you change so it doesn't happen again.

    Covers diagnosing an EF Core query performance regression end to end: Application Insights release comparison and dependencies, Query Store regressed queries and plans, TagWith to map SQL to code, finding the LINQ change in the diff, mitigation (rollback, forced plan) and prevention.

    Senior RealWorldScenario EF Core Performance Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  18. Code review: a monthly sales report method loads the whole Orders table with its lines into memory as tracked entities, groups and sums in LINQ to Objects, builds a CSV by concatenating strings in a loop, and runs inside a request with no timeout. What do you flag, in what order, and what does the rewrite look like?

    A senior EF Core code review of a slow report: loading a whole table with Include and tracking, in-memory grouping instead of SQL aggregation, string concatenation, no streaming, no cancellation or timeout, ranked by severity with a rewrite.

    Senior CodeReview EF Core Performance Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  19. How do you add a foreign key or CHECK constraint to a large, live SQL Server table without blocking writes or failing on existing bad data?
    Senior Theory Production EF
  20. How would you test EF Core migrations before they reach production so that data problems and long locks are caught early?
    Senior RealWorldScenario Production EF

🌐 Sangam's Webring

βͺ Previous 🏠 Main Next ⏩
πŸ’¬ Chat with me