Mert Özen Further With Every Line

Blog

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

Series
28 posts found #veritabani
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 3
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 2
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 2
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 3
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 2
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 5
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 3
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 2
Seeding in EF Core: Model Seeding with HasData and Application-Side Seeding
Database PART 08

Seeding in EF Core: Model Seeding with HasData and Application-Side Seeding

Two ways to add initial data in EF Core: model seeding with HasData and the InsertData/UpdateData/DeleteData it generates, the key and navigation rules, the dynamic value trap; then a rerunnable application-side seeder and a pointer to EF Core 9's UseSeeding.

5 Nov 2026 12 min 2
EF Core Migrations: migrations add, database update, Scripts and Bundles
Database PART 07

EF Core Migrations: migrations add, database update, Scripts and Bundles

We run EF Core migrations end to end: migrations add/remove, database update and reverting, the anatomy of a migration file, SQL scripts and --idempotent, EF Core 6 migration bundles, and the risks of calling Migrate() at startup.

5 Nov 2026 10 min 2
Relationships in EF Core, Part 2: One-to-One, Many-to-Many and UsingEntity
Database PART 06

Relationships in EF Core, Part 2: One-to-One, Many-to-Many and UsingEntity

We build one-to-one with Author and AuthorProfile and many-to-many with Book and Tag: the unique foreign key index, the dependent-side error and HasForeignKey<T>, skip navigations and the BookTag table created by convention, naming the join table with UsingEntity and a join entity with a TaggedAt payload.

5 Nov 2026 10 min 2
Relationships in EF Core, Part 1: One-to-Many, Foreign Keys and Cascade Delete
Database PART 05

Relationships in EF Core, Part 1: One-to-Many, Foreign Keys and Cascade Delete

We build a one-to-many relationship with Author and Book: principal, dependent and foreign key, how the convention finds the relationship, HasOne/WithMany in the Fluent API, adding graphs and fixup, required versus optional relationships, and real SQLite output for Cascade, ClientSetNull and Restrict with loaded and unloaded dependents.

5 Nov 2026 10 min 3
Blog Map