Skip to main content

November 2026

Every post published in November 2026, newest first. Pick a day to jump straight to it.

Posts
802
Topics
75
Reading time
91 h
Active days
15

Posts 481–510 of 802 · November 5, 2026

Page 17 of 27

Thursday, November 5, 2026

30 of 124 posts

  1. How to Test a Race Condition in a Web API from the Terminal

    Send several requests at the same moment with xargs and curl, or ForEach-Object -Parallel in PowerShell, then compare status codes and database values. Run it more than once, because a race can pass by luck. Real output against an ASP.NET Core API.

  2. How to Validate Several Fields Together with IValidatableObject in a Minimal API

    For rules attributes can't express, such as no duplicates in a list, implement IValidatableObject on the request. AddValidation calls it after the attributes pass. Real code and output from ASP.NET Core 10.

  3. How to Validate a List Inside a Minimal API Request

    With AddValidation, attributes on a list's items are checked too, and errors come back with keys like Lines[0].ProductId. Here's how to limit the list's size, validate each item, and read the errors. Real output from ASP.NET Core 10.

  4. How to Return Enums as Strings in Minimal API JSON

    Add JsonStringEnumConverter in ConfigureHttpJsonOptions, and every minimal API endpoint reads and writes enum names. Here's what it accepts on the way in, and how to refuse numbers. Real output from ASP.NET Core 10.

  5. How to Write an IExceptionHandler in ASP.NET Core

    IExceptionHandler lets you turn chosen exceptions into proper HTTP responses in one place, and leave the rest as 500s. Here's a complete handler, its registration, and the .NET 10 logging change to know about. Real output from ASP.NET Core 10.

  6. How to Return 503 with a Retry-After Header in ASP.NET Core

    When the database can't do something right now, a 500 tells clients it's a bug. An exception handler can answer 503 with Retry-After and a problem details body instead. Real code and output from ASP.NET Core 10, for an outage, a lock wait and a full pool.

  7. How to Read a Request Header in a Minimal API with FromHeader

    Add a [FromHeader] parameter, with Name for headers that have dashes. string? makes it optional, string makes it required, and HttpContext is there for anything unusual. Real output from ASP.NET Core 10.

  8. How to Add an Idempotency-Key Header to a POST Endpoint in ASP.NET Core

    An Idempotency-Key header lets a client repeat a POST safely: the same key returns the first result, and a unique index settles a race. Six simultaneous requests with one key made one order. Real code and output from ASP.NET Core 10, EF Core 10 and MySQL 9.7.

  9. How to Sum a Column with SumAsync in EF Core

    SumAsync adds up a column in the database, returns 0 for no rows thanks to COALESCE, and works per group with GroupBy. Here's the code, the SQL and the results. Real output from EF Core 10 and MySQL 9.7.

  10. How to Find Rows by a List of IDs with Contains in EF Core

    ids.Contains(p.Id) in a Where becomes SQL's IN, with a parameter for each value, and an empty list becomes WHERE FALSE, with no error. Here's the code, the SQL, and how to read a list from the query string. Real output from EF Core 10 and MySQL 9.7.

  11. How to Share a Transaction Between Two DbContexts in EF Core

    Two DbContext instances can work in one transaction if they share a connection and you call UseTransactionAsync on the second. Both commit or roll back together. Real code and output from EF Core 10 and MySQL 9.7.

  12. How to Use TransactionScope with EF Core and MySQL

    TransactionScope works with EF Core and MySql.Data, as long as you turn on async flow, put it inside the execution strategy, and pass an isolation level. Here's each of those, with MySQL's log. Real output from .NET 10 and MySQL 9.7.

  13. How to Use ChangeTracker.Clear in EF Core

    ChangeTracker.Clear makes a DbContext forget every entity it's tracking, including unsaved changes. Here's what it does, when it's useful, and how it stops a retry saving a row twice. Real output from EF Core 10 and MySQL 9.7.

  14. How to Read the MySQL Error Number from an EF Core Exception

    SaveChanges wraps MySQL's error in a DbUpdateException, ExecuteUpdate doesn't, and a retry wraps it in something else. A small extension method finds the MySqlException in any of them, so you can act on the number. Real output from EF Core 10 and MySQL 9.7.

  15. How to Run Raw SQL in EF Core: FromSql, SqlQuery and ExecuteSql

    EF Core has three methods for your own SQL: FromSql returns entities, SqlQuery returns anything else, and ExecuteSql changes data. All three turn interpolated values into parameters. Real output from EF Core 10 and MySQL 9.7.

  16. How to Prevent Overselling with a Conditional UPDATE in EF Core

    Put the stock check in the UPDATE's WHERE with ExecuteUpdateAsync, and read the row count. One order wins and the rest get a 409, every time, with no locks held in C#. Real code and output from EF Core 10 and MySQL 9.7.

  17. How to Set a Lock Wait Timeout from EF Core

    MySQL's default lock wait is 50 seconds, which is far too long for a web request. Set a shorter one on every connection from EF Core, and turn the failure into a useful answer. Real output from EF Core 10 and MySQL 9.7.

  18. How to Run SQL When a Connection Opens in EF Core

    A DbConnectionInterceptor runs your SQL each time EF Core opens a connection, which is how to set session variables such as lock and query limits. It adds about 0.07 ms per request. Real code and output from EF Core 10 and MySQL 9.7.

  19. How to Use Savepoints in EF Core

    CreateSavepointAsync and RollbackToSavepointAsync let part of a transaction fail while the rest commits. EF Core also creates savepoints of its own around SaveChanges. Here's the log from MySQL, and how to turn those off. Real output from EF Core 10 and MySQL 9.7.

  20. How to Set the Transaction Isolation Level in EF Core

    Pass an IsolationLevel to BeginTransactionAsync, and check it worked in MySQL's own tables. The driver sends SET TRANSACTION ISOLATION LEVEL for every transaction, and Snapshot isn't available. Real output from EF Core 10 and MySQL 9.7.

  21. How to Lock a Row with SELECT FOR UPDATE in EF Core

    EF Core has no LINQ method for FOR UPDATE, so use FromSql in a transaction. The row stays locked until the commit, so you can check it in C# safely. See when it's worth it, and when a conditional UPDATE is simpler. Real output from EF Core 10 and MySQL 9.7.

  22. How to Use ExecuteInTransactionAsync in EF Core

    ExecuteInTransactionAsync begins, commits and retries for you, and it calls a function you supply when the commit's outcome is unknown. Here's that function being called after a lost COMMIT, with one row saved. Real output from EF Core 10 and MySQL 9.7.

  23. How to Use ExecuteUpdateAsync and SaveChangesAsync in One Transaction

    ExecuteUpdateAsync runs immediately, so it isn't part of SaveChanges. Put both in a transaction you start yourself, and they succeed or fail together. Here's the code, MySQL's log, and the failure that shows why. Real output from EF Core 10 and MySQL 9.7.

  24. How to Write a Custom Execution Strategy in EF Core for MySQL

    A small ExecutionStrategy subclass decides exactly which MySQL errors to retry, tells a dropped connection from a full pool, and closes broken connections before each retry. 96 of 96 requests got through a MySQL restart. Real code and output from EF Core 10 and MySQL 9.7.

  25. How to Make EnableRetryOnFailure Retry MySQL Errors in EF Core

    With Oracle's MySQL provider, EnableRetryOnFailure retries nothing until you list the error numbers. Here's which numbers to list, how to check it's working, how long it waits, and what it can't do. Real output from EF Core 10 and MySQL 9.7.

  26. How to Use a Transaction with a Retrying Execution Strategy in EF Core

    With retries on, BeginTransactionAsync alone fails. Put the whole transaction in CreateExecutionStrategy().ExecuteAsync, state the lambda's return type, and make every attempt start clean. Real code and output from EF Core 10 and MySQL 9.7.

  27. How to See EF Core Transactions in the Logs

    EF Core logs when a transaction begins, commits and rolls back, at Debug level, so by default you don't see it. One line in appsettings.Development.json shows it. Real output from EF Core 10.

  28. How to Use a Transaction in EF Core with BeginTransactionAsync

    Group several SaveChangesAsync or ExecuteUpdateAsync calls into one all-or-nothing unit with BeginTransactionAsync and CommitAsync. See what happens when you don't commit, roll back by hand, or fail partway. Real output from EF Core 10 and MySQL 9.7.

  29. Does EF Core's SaveChanges Use a Transaction?

    Yes: one SaveChanges call is one transaction, so if a row fails, none are saved. Here's the proof in MySQL's own log, what happens with the behaviour switched off, and when you still need your own transaction. Real output from EF Core 10 and MySQL 9.7.

  30. How to Change a Row's Status Only Once in MySQL

    Two people close the same ticket at once, or an order gets cancelled twice. Put the current status in the UPDATE's WHERE, and only the first one changes anything. ROW_COUNT tells each of them who won. Run live on MySQL 9.7, with two sessions at the same moment.