Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Connection Resiliency, Logging and Diagnostics in EF Core: Execution Strategies, Command Timeouts, TagWith, Events and Metrics
In EF Core, EnableRetryOnFailure retries SQL Server's transient errors with exponential backoff; your own transaction must run inside CreateExecutionStrategy or ExecuteInTransactionAsync with an idempotent RequestId. Command timeouts aren't retried; log categories, TagWith/TagWithCallSite, DiagnosticListener, OpenTelemetry and the Microsoft.EntityFrameworkCore meter show which code sent which SQL.
EF Core Migrations in Practice: Rename vs Drop, Data Migrations, Managing Views/SPs in Migrations, Team Conflicts and Squashing
Always read the generated migration: when FullName is split into FirstName/LastName, EF Core may produce a RenameColumn that moves the data into the wrong column. Data steps are written with migrationBuilder.Sql and EXEC, views and functions inside migrations or with a custom MigrationOperation; diverged migrations on a team are regenerated, and a long history is squashed into a Baseline by hand.
The EF Core Fluent API Catalog: Column Types, Default and Computed Values, Sequences and HiLo, Index Options and Bulk Conventions
In EF Core, column types are set with HasMaxLength, IsUnicode, IsFixedLength, HasPrecision and UseCollation, generated values with HasDefaultValueSql, HasComputedColumnSql, HasSequence and UseHiLo, and indexes with IsUnique, HasFilter, IncludeProperties and IsDescending; ConfigureConventions gives every string and decimal a default in one line. HasDefaultValue does not send the CLR default (0, false) to the database.
The EF Core LINQ-to-SQL Translation Catalog: Strings, DateTime, Math, Collections, EF.Functions and HasDbFunction
On SQL Server, EF Core translates string methods to LIKE, UPPER, SUBSTRING and STRING_AGG, dates to DATEADD/DATEPART/DATEDIFF and collections to IN and OPENJSON; SQL features with no C# equivalent come through EF.Functions, and your own functions are bound to LINQ with HasDbFunction. Translations that wrap the column in a function (ToLower, DATEDIFF) make the index unusable.
Database-First with EF Core: Generating a Model from an Existing Database, Scaffold Options, T4 Templates and Re-Scaffolding
An EF Core model is generated from an existing database with dotnet ef dbcontext scaffold; the connection string is read from configuration with Name=, and --schema/--table, --use-database-names, --no-pluralize and --no-onconfiguring shape the output. When the code will be re-scaffolded, customizations live in partial classes, OnModelCreatingPartial and T4 templates.
What's New in EF Core 10: Named Query Filters, LeftJoin and Complex Types in JSON
Named query filters and IgnoreQueryFilters(["..."]), LeftJoin/RightJoin, ExecuteUpdateAsync with a regular lambda, complex types and ComplexCollection mapped to JSON, padded parameterized collections, vector search with SqlVector and the SQLite DateTimeOffset breaking change in EF Core 10 LTS.