📁 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.

Advanced EF Core

Transactions, raw SQL, interceptors, compiled queries, global query filters, temporal tables, JSON columns, table splitting, TPH, TPT and TPC, concurrency tokens and RowVersion, bulk operations, query tags and execution strategies.

  1. How do you handle the commit-in-doubt case when a retrying execution strategy loses the connection during COMMIT?
    Intermediate Theory Advanced EF Core
  2. How do you map and call a SQL Server table-valued function from EF Core so it composes with LINQ?
    Mid-Level Theory Advanced EF Core
  3. How do you combine an EF Core tenant filter with SQL Server row-level security, and why would you want both?
    Mid-Level Theory Advanced EF Core
  4. How do transactions work in EF Core? Explain the implicit transaction around SaveChanges, when you would call BeginTransaction yourself, what savepoints do, why TransactionScope needs care, and how all of this interacts with a retrying execution strategy on Azure SQL.

    Covers EF Core transactions: the implicit SaveChanges transaction and AutoTransactionBehavior, explicit BeginTransaction and UseTransaction, automatic and manual savepoints, TransactionScope pitfalls (Serializable default, async flow, no distributed transactions on Azure SQL) and wrapping explicit transactions in the execution strategy.

    Intermediate Theory Advanced EF Core Β· πŸ”— 3 follow-ups
  5. When and how do you use raw SQL in EF Core? Compare FromSql, FromSqlRaw and SqlQuery<T>, explain ExecuteSql, show how SQL injection can still happen through string interpolation, and explain when you can compose LINQ on top of a raw query.

    Covers EF Core raw SQL APIs (FromSql/FromSqlInterpolated, FromSqlRaw, SqlQuery and SqlQueryRaw, ExecuteSql and ExecuteSqlRaw), how interpolated strings become parameters, the injection traps with FromSqlRaw and dynamic identifiers, the EF1002 analyser, and composing LINQ over composable SQL versus stored procedures.

    Mid-Level Security Advanced EF Core Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  6. What are EF Core interceptors? Explain command, SaveChanges and connection interceptors, how you register them and what lifetime they effectively have, and give real production uses, including what they cannot see.

    Covers EF Core interceptors: IDbCommandInterceptor, ISaveChangesInterceptor, IDbConnectionInterceptor, IMaterializationInterceptor and IQueryExpressionInterceptor; registration with AddInterceptors and DI; lifetime with pooling; suppression results; real uses (audit columns, soft delete, slow-query logging, query hints, Entra ID tokens) and the fact that ExecuteUpdate/ExecuteDelete bypass SaveChanges interceptors.

    Mid-Level Theory Advanced EF Core Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  7. What are global query filters in EF Core? Explain how they are applied to queries, how per-request values such as a tenant id get into them, how IgnoreQueryFilters and the named filters added in EF Core 10 work, and the pitfalls with required navigations and indexes.

    Covers EF Core global query filters: HasQueryFilter, how filters are added to every LINQ query (including Include, Find and ExecuteUpdate), parameterising them through DbContext members, IgnoreQueryFilters, EF Core 10 named filters, the required-navigation INNER JOIN pitfall (warning 10622), one filter per hierarchy root and indexing for filtered columns.

    Mid-Level Theory Advanced EF Core Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  8. How do you use SQL Server temporal tables with EF Core? Explain the configuration, the TemporalAsOf, TemporalAll and related query operators, using them to audit or restore data, and what they cost in storage and operations.

    Covers SQL Server system-versioned temporal tables in EF Core 6+: IsTemporal configuration, period columns as shadow properties, migrations, the TemporalAsOf/All/FromTo/Between/ContainedIn operators, restoring deleted rows, what temporal tables don't record (who changed it), history growth and retention, and alternatives such as audit tables and ledger tables.

    Mid-Level Theory Advanced EF Core Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  9. How do JSON columns work in EF Core 10? Explain mapping with ToJson on complex and owned types, how queries inside the JSON are translated, what the native SQL Server json type changes, how updates and indexing work, and when a JSON column is better than extra tables.

    Covers EF Core JSON mapping: ToJson on owned types (EF Core 7+) and complex types (EF Core 10), primitive collections, translation to JSON_VALUE/OPENJSON, partial updates with JSON_MODIFY, the native json data type used with Azure SQL and SQL Server 2025 (compatibility level 170), indexing through computed columns, ExecuteUpdate on JSON properties, and the design trade-offs versus normalised tables.

    Mid-Level Theory Advanced EF Core Β· πŸ”— 2 follow-ups Β· πŸ›  1 real-world
  10. How does EF Core map an inheritance hierarchy? Compare TPH, TPT and TPC: the schema each produces, the SQL for polymorphic and leaf-type queries, how keys and foreign keys work, the performance trade-offs, and which you would choose for a new system.

    Covers EF Core inheritance mapping strategies: table-per-hierarchy with a discriminator (default), table-per-type (EF Core 5+) and table-per-concrete-type (EF Core 7+); generated SQL for polymorphic and leaf queries (single table, JOINs, UNION ALL); key generation across TPC tables with sequences; foreign keys to the base type; nullability and constraint trade-offs; and how to choose.

    Senior Theory Advanced EF Core Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  11. Show how you implement optimistic concurrency in EF Core. Use a RowVersion or a concurrency token, explain the SQL EF Core sends, handle DbUpdateConcurrencyException with a client-wins, store-wins or merge strategy, and return the right HTTP response from an API.

    Covers EF Core optimistic concurrency: [Timestamp]/IsRowVersion on SQL Server rowversion, app-managed concurrency tokens with IsConcurrencyToken, the UPDATE ... WHERE RowVersion = @original pattern, setting OriginalValue from the client, DbUpdateConcurrencyException with GetDatabaseValuesAsync and store-wins/client-wins/merge resolution, concurrency with ExecuteUpdate, and mapping to 409 or ETag/If-Match with 412.

    Mid-Level Coding Advanced EF Core Β· πŸ”— 3 follow-ups Β· πŸ›  1 real-world
  12. 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
  13. 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
  14. 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

🌐 Sangam's Webring

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