Mert Özen Further With Every Line

Blog

Mert Özen's blog posts on software development, backend, frontend, and DevOps.

Series
44 posts found
Owned Types and Value Converters in EF Core: Addresses, Enums and Strongly Typed Ids
Database PART 20

Owned Types and Value Converters in EF Core: Addresses, Enums and Strongly Typed Ids

We tie identity-less values to their owner with OwnsOne and OwnsMany, store enums as text and wrap Ids in their own types. With real output we see a change lost for lack of a value comparer and an OwnsMany pitfall specific to SQLite.

5 Nov 2026 11 min 12
Inheritance Mapping in EF Core: TPH, TPT and When to Choose Which
Database PART 19

Inheritance Mapping in EF Core: TPH, TPT and When to Choose Which

How does EF Core turn a class hierarchy into tables? We compare TPH with its discriminator column and TPT with a table per type using real SQL output, and look at silent pitfalls like a subclass missing from the model.

5 Nov 2026 12 min 10
Global Query Filters in EF Core: Soft Delete, Multi-Tenancy and IgnoreQueryFilters
Database PART 18

Global Query Filters in EF Core: Soft Delete, Multi-Tenancy and IgnoreQueryFilters

We build soft delete and multi-tenancy with HasQueryFilter, turn Remove into an UPDATE, switch filters off with IgnoreQueryFilters, and examine relationship pitfalls such as rows that vanish through an INNER JOIN on required navigations, with real SQL.

5 Nov 2026 9 min 12
EF Core Performance Basics: N+1, Projection, AsNoTracking and Compiled Queries
Database PART 17

EF Core Performance Basics: N+1, Projection, AsNoTracking and Compiled Queries

We catch N+1 queries by counting commands, switch to DTO projections, measure the effect of tracking, indexes, split queries and compiled queries on SQLite, and monitor queries with TagWith and LogTo.

5 Nov 2026 9 min 14
EF Core in ASP.NET Core: AddDbContext, Scoped Lifetime, Factory and Pooling
Database PART 16

EF Core in ASP.NET Core: AddDbContext, Scoped Lifetime, Factory and Pooling

We wire DbContext into ASP.NET Core with AddDbContext, watch the scoped lifetime through ContextId, solve the singleton and background service traps, and see with real output when AddDbContextFactory and AddDbContextPool help.

5 Nov 2026 8 min 14
Raw SQL in EF Core: FromSqlRaw, FromSqlInterpolated, Keyless Entities and SQL Injection
Database PART 15

Raw SQL in EF Core: FromSqlRaw, FromSqlInterpolated, Keyless Entities and SQL Injection

We look at FromSqlRaw versus FromSqlInterpolated, the SQL produced when LINQ is composed on top, the SQL injection trap with $, ExecuteSql commands, keyless entities mapped to views, and calling stored procedures on SQL Server, all with real output.

5 Nov 2026 10 min 12
Concurrency in EF Core: Tokens, rowversion and DbUpdateConcurrencyException
Database PART 14

Concurrency in EF Core: Tokens, rowversion and DbUpdateConcurrencyException

We reproduce a lost update, set up optimistic concurrency with a concurrency token, use rowversion on SQL Server and a Guid version column on SQLite, and resolve DbUpdateConcurrencyException with a retry loop.

5 Nov 2026 10 min 12
Transactions in EF Core: SaveChanges, BeginTransaction and Savepoints
Database PART 13

Transactions in EF Core: SaveChanges, BeginTransaction and Savepoints

We watch SaveChanges' implicit transaction in the logs, turn several SaveChanges calls into one unit with BeginTransaction, roll back part of the work with savepoints, and look at the pitfalls of TransactionScope and retry strategies.

5 Nov 2026 11 min 11
Saving Data with EF Core: SaveChanges, Related Graphs and Disconnected Entities
Database PART 12

Saving Data with EF Core: SaveChanges, Related Graphs and Disconnected Entities

The two worlds of saving data in EF Core: Add/Remove and SaveChanges writing only changed columns in the connected scenario, batching on SQLite and SQL Server, saving related graphs and orphans; Update writing every column, load-and-change, SetValues, Attach and IsModified in the disconnected scenario.

5 Nov 2026 11 min 11
Change Tracking in EF Core: Entity States, AsNoTracking and Identity Resolution
Database PART 11

Change Tracking in EF Core: Entity States, AsNoTracking and Identity Resolution

We open up EF Core's change tracker: the five entity states, ChangeTracker.Entries and DebugView, the one-object-per-row rule (identity resolution), AsNoTracking vs AsNoTrackingWithIdentityResolution, when DetectChanges runs, and the 'already being tracked' error.

5 Nov 2026 10 min 15
Loading Related Data in EF Core: Include, Explicit and Lazy Loading, Split Queries
Database PART 10

Loading Related Data in EF Core: Include, Explicit and Lazy Loading, Split Queries

We compare the three ways to load related data in EF Core with real SQL output: Include/ThenInclude and filtered include, explicit loading with the Entry API, lazy loading with proxies and its N+1 bill; then cartesian explosion and AsSplitQuery.

5 Nov 2026 12 min 14
LINQ Queries with EF Core: SQL Translation, Client Evaluation and the IQueryable Trap
Database PART 09

LINQ Queries with EF Core: SQL Translation, Client Evaluation and the IQueryable Trap

We follow how an EF Core LINQ query becomes SQL: deferred execution, ToQueryString and LogTo, filtering, sorting and paging, projection, First/Single/Find, client evaluation allowed in the final Select, and the IEnumerable trap that silently pulls the whole table.

5 Nov 2026 12 min 12
Blog Map