Skip to main content
SEMastery

Data Access

Explore data access topics and best practices in the .NET ecosystem.

Level:
67 articles
intermediate

Soft Delete with EF Core: Delete Data Without Losing It

Learn soft delete in EF Core the right way. Use an interceptor and global query filters to hide deleted rows automatically, with simple examples, diagrams, code, and best practices for .NET 10.

11 minEF Core · soft delete
intermediate

Understanding Change Tracking for Better Performance in EF Core

Learn how EF Core change tracking works, the entity states it uses, and simple tricks like AsNoTracking to make your .NET apps faster.

11 minef-core · performance
intermediate

What's New in EF Core 10: LeftJoin and RightJoin in LINQ

Learn the new LeftJoin and RightJoin LINQ operators in EF Core 10. Simple examples, SQL mapping, and clear tables to help you write cleaner join queries.

12 minef-core · ef-core-10
intermediate

Calling Views, Stored Procedures and Functions in EF Core

A friendly, beginner guide to calling database views, stored procedures, and functions in EF Core with FromSql, SqlQuery, ExecuteSql, and ToView.

11 minef-core · dotnet
intermediate

Multi-Tenant Applications With EF Core: A Beginner's Guide

Learn multi-tenancy in EF Core the simple way. Isolate tenant data with global query filters, ITenantService, and named filters in .NET 10, with diagrams and code.

12 minEF Core · multi-tenancy
beginner

Get Started with SQL Transactions in PostgreSQL

Learn SQL transactions in PostgreSQL the easy way: BEGIN, COMMIT, ROLLBACK, ACID, savepoints, and isolation levels with simple diagrams and C# examples.

12 minPostgreSQL · SQL
intermediate

The Real Cost of Returning the Identity Value in EF Core

Why EF Core asking the database for the new Id after every insert costs round trips, and how HiLo, sequences, and Guids cut that cost down.

11 minef-core · performance
beginner

How to Use Global Query Filters in EF Core (Beginner Guide)

Learn EF Core global query filters with simple examples for soft delete and multi-tenancy, plus the new named filters in EF Core 10.

11 minef-core · dotnet
beginner

Optimizing SQL Performance with Indexing Strategies for Faster Queries

Learn SQL indexing the easy way: clustered, nonclustered, covering and composite indexes, with simple diagrams and C# examples to make your queries fast.

13 minSQL · indexing
beginner

Eager Loading of Child Entities in EF Core: A Beginner's Guide

Learn eager loading in EF Core with Include and ThenInclude. Load child entities in one query, avoid the N+1 problem, and use filtered Include with simple examples.

11 minEF Core · eager loading
intermediate

EF Core Bulk Insert: Boost Performance with Entity Framework Extensions

Learn how EF Core bulk insert with Entity Framework Extensions saves data faster, using simple examples, diagrams, and clear performance comparisons.

11 minef-core · bulk-insert
beginner

Boost Your EF Core Productivity in PostgreSQL With Entity Developer

Learn how Entity Developer gives EF Core a visual ORM designer for PostgreSQL, with drag-and-drop modeling, model-first and database-first, and T4 code generation.

13 minEF Core · PostgreSQL
beginner

EF Core DbContext Options Explained: A Beginner's Friendly Guide

Learn EF Core DbContext options in simple words: AddDbContext, the options builder, retry on failure, query splitting, logging, lifetimes and pooling, with diagrams and examples.

12 minEF Core · DbContext
intermediate

Build a Multi-Model AI Chat Bot in .NET with ChatGPT and Neon Postgres Branching

Learn to build a multi-model AI chat bot in .NET 10 using ChatGPT and Neon serverless Postgres branching, with simple steps a beginner can follow.

13 mindotnet · neon
beginner

EF Core Raw SQL Queries: FromSql, SqlQuery, and ExecuteSql Explained

A friendly, beginner guide to raw SQL in EF Core: FromSql for entities, SqlQuery for scalars, ExecuteSql for writes, and how to stay safe from SQL injection.

13 minEF Core · raw SQL
beginner

Introduction to Locking and Concurrency Control in .NET 6

A beginner-friendly guide to locking and concurrency control in .NET 6 and EF Core, with a simple analogy, diagrams, code, and optimistic vs pessimistic locking.

12 minEF Core · concurrency
beginner

Fast SQL Bulk Inserts With C# and EF Core: A Beginner Guide

Learn fast SQL bulk inserts in C# and EF Core using AddRange, batching, SqlBulkCopy, and bulk libraries, with simple diagrams and clear examples.

11 minef-core · bulk-insert
intermediate

EF Core Query Optimization: From 30 Seconds to 30 Milliseconds

Learn EF Core query optimization step by step: fix N+1 queries, use projections, AsNoTracking, indexes, and compiled queries to turn a 30-second query into 30ms.

11 minEF Core · performance
intermediate

EF Core Query Splitting: Fix Slow Queries and Cartesian Explosion

Learn how EF Core query splitting (AsSplitQuery) fixes the cartesian explosion problem with simple examples, diagrams, and real performance numbers. Know when to split and when not to.

12 minEF Core · performance
beginner

EF Core Migrations: A Detailed Beginner Guide for .NET

Learn EF Core migrations step by step. Add, apply, revert, and ship database changes safely with simple examples, diagrams, tables, and best practices for .NET 10.

13 minEF Core · migrations
intermediate

From Transaction Scripts to Domain Models: A Refactoring Journey

Learn how to refactor messy transaction script code into a clean domain model in .NET 10. Simple examples, diagrams, tables, and EF Core code to guide your journey.

12 mindomain model · transaction script
intermediate

How I Increased a Production Payment System's Performance by 15x With EF Core Extensions

A true-to-life story of making a slow EF Core payment system 15x faster using bulk extensions, ExecuteUpdate, and ExecuteDelete with simple examples.

12 minef-core · bulk-extensions
intermediate

Understanding Cursor Pagination and Why It's So Fast: A Deep Dive

A friendly deep dive into cursor (keyset) pagination: how it works, why it stays fast on deep pages, how to build it in EF Core, with diagrams and code.

13 mincursor pagination · keyset pagination
intermediate

Using Multiple EF Core DbContext in a Single Application

Learn how to use multiple EF Core DbContext classes in one .NET app. See when to split, how to register, migrate, and coordinate them with simple examples.

12 minEF Core · DbContext
beginner

How to Use EF Core Interceptors: A Beginner-Friendly Guide

Learn EF Core interceptors step by step. Add auditing, soft delete, logging, and timing to your DbContext with clean, reusable code and zero clutter.

11 minef-core · interceptors
beginner

Getting Started With MongoDB in EF Core: A Beginner's Guide

A friendly beginner guide to using MongoDB with EF Core in .NET. Learn setup, DbContext, UseMongoDB, CRUD, mapping, and the limits you must know.

13 minmongodb · ef-core
intermediate

Zero-Downtime Migrations: A Practical Demo with Password Hashing

Learn zero-downtime migrations with a real password hashing demo in ASP.NET Core. Upgrade old hashes safely as users log in, with diagrams and code.

12 minzero-downtime · database migration
beginner

Why Every EF Core Developer Needs to Try Entity Framework Extensions

A friendly guide to Entity Framework Extensions: bulk insert, update, delete and merge for EF Core, with simple analogies, diagrams, tables and code examples.

12 minEF Core · Entity Framework Extensions
intermediate

Solving Race Conditions With EF Core Optimistic Locking

Learn how EF Core optimistic locking with RowVersion stops race conditions and lost updates, with simple examples, diagrams, and retry patterns.

12 minef-core · concurrency
beginner

5 Hidden EF Core NuGet Packages That Make Your .NET Code Better

Five lesser-known EF Core NuGet packages for clean exceptions, naming conventions, bulk speed, dynamic queries, and auditing — with simple examples and diagrams.

11 minEF Core · NuGet
intermediate

How to Customize ASP.NET Core Identity With EF Core for Your Project Needs

Learn to customize ASP.NET Core Identity with EF Core: add user fields, change the key type, extend roles, and run migrations safely on .NET 10.

11 minaspnet-core · identity
beginner

Getting Started With Database Views in SQL: A Beginner's Guide

Learn SQL database views from scratch: what they are, how to create them, when to use them, and how indexed views speed up queries. Simple and beginner-friendly.

13 minsql · database
intermediate

DbContext Is Not Thread-Safe: Parallelizing EF Core Queries the Right Way

Learn why EF Core DbContext is not thread-safe and how to run parallel queries safely using IDbContextFactory in .NET 10. Beginner friendly.

12 minef-core · dbcontext
intermediate

Global Query Filters in EF Core: Soft Delete and Multi-Tenancy Made Easy

Learn EF Core global query filters with simple examples for soft delete and multi-tenancy, plus the new named filters in .NET 10.

12 minef-core · dotnet
beginner

How I Made My EF Core Query Faster With Batching

A beginner-friendly guide to EF Core batching. Learn how SaveChanges groups SQL into fewer database trips, how to tune MaxBatchSize, and when it helps.

11 minEF Core · batching
intermediate

How to Create Migrations for Multiple Databases in EF Core (.NET 10)

Learn how to create EF Core migrations for multiple databases like SQL Server, SQLite, and PostgreSQL using separate migration projects, with simple examples.

11 minEF Core · migrations
intermediate

Unleash EF Core Performance With Compiled Queries

Learn EF Core compiled queries in .NET 10 with EF.CompileQuery and EF.CompileAsyncQuery. Simple words, real examples, and clear before-and-after numbers.

12 minEF Core · compiled queries
intermediate

Debunking the Filter Early, JOIN Later SQL Performance Myth

The 'filter before you JOIN' tip is mostly a myth. Modern SQL optimizers already push predicates down. Learn what really happens and how to write clean SQL.

11 minSQL · performance
intermediate

Working With Transactions in EF Core: A Beginner-Friendly Guide

Learn how transactions work in EF Core with simple examples, savepoints, TransactionScope, execution strategies, diagrams, and clear best practices.

12 minef-core · transactions
intermediate

A Clever Way to Implement Pessimistic Locking in EF Core

Learn pessimistic locking in EF Core using UPDLOCK and FOR UPDATE with a simple analogy, diagrams, and a clean reusable helper. Stop race conditions on shared rows.

11 minEF Core · pessimistic locking
intermediate

How to Use the New Bulk Update Feature in EF Core 7

Learn EF Core 7 bulk updates with ExecuteUpdate and ExecuteDelete. Update or delete many rows in one fast SQL trip, no entity loading needed.

11 minef-core · csharp
intermediate

Named Global Query Filters in EF Core 10: Multiple Filters Per Entity

Learn how EF Core 10 adds named global query filters so you can use multiple filters per entity and turn off just one filter when you need to.

11 minef-core · dotnet-10
intermediate

Mastering Dapper Relationship Mappings: A Friendly Guide

Learn Dapper multi-mapping in .NET with splitOn for one-to-one, one-to-many, and many-to-many relationships. Simple examples, diagrams, and clear tips.

13 minDapper · multi-mapping
intermediate

Querying and Performing Transactions Across Multiple Database Schemas in a Modular Monolith

Learn how to query data and run safe transactions across multiple database schemas in a .NET modular monolith using EF Core, the outbox pattern, and more.

12 minmodular-monolith · ef-core
beginner

The New .slnx Solution Format: A Simple Migration Guide for .NET 10

Learn the new XML-based .slnx solution format in .NET 10, why it beats the old .sln file, and how to migrate safely with one CLI command.

12 mindotnet-10 · slnx
intermediate

What You Need to Know About EF Core Bulk Updates

A friendly guide to EF Core bulk updates with ExecuteUpdate and ExecuteDelete. Change many rows in one fast SQL trip, plus the traps to avoid.

12 minef-core · csharp
intermediate

How To Fix Slow Write Queries in Dapper With the Dapper Plus Library

Learn why Dapper inserts and updates get slow for big batches, and how Dapper Plus BulkInsert, BulkUpdate, BulkMerge make writes up to 75x faster.

11 mindapper · dapper-plus
intermediate

The Correct Way to Use Batch Update and Batch Delete in EF Core

Learn the correct, safe way to use ExecuteUpdate and ExecuteDelete batch methods in EF Core, with transactions, change tracker tips, and EF Core 10 features.

13 minef-core · dotnet
intermediate

How to Increase EF Core Performance for Read Queries in .NET

Make EF Core read queries fast in .NET 10 with AsNoTracking, projections, split queries, pagination, indexes, and compiled queries. Simple words and real examples.

13 minEF Core · performance
intermediate

How to Implement an Audit Trail in ASP.NET Core with EF Core

Build an automatic audit trail in ASP.NET Core with EF Core using a SaveChanges interceptor and the ChangeTracker. Simple examples, diagrams, and best practices for .NET 10.

11 minEF Core · audit trail
beginner

A Complete Guide to Different Types of Joins in SQL

Learn SQL joins the easy way: INNER, LEFT, RIGHT, FULL OUTER, CROSS and SELF joins explained with simple tables, diagrams, and C# examples.

14 minSQL · joins
intermediate

Best Practices When Working With MongoDB in .NET

Learn simple, proven MongoDB best practices in .NET: singleton client, connection pooling, indexes, projections, and safe writes explained for beginners.

11 minmongodb · dotnet
intermediate

Building a Multitenant Cloud Application With Azure Functions and Neon Postgres

A beginner-friendly guide to building a multitenant cloud app with Azure Functions and Neon serverless Postgres, using a database-per-tenant design in .NET.

12 minAzure Functions · Neon
intermediate

Optimizing Bulk Database Updates in .NET: A Practical Guide

Learn how to make bulk database updates fast in .NET using EF Core ExecuteUpdate, batching, and transactions, with simple examples and EF Core 10 tips.

12 minef-core · dotnet
beginner

Exploring Data Mapping Options in EF Core: A Beginner's Guide

Learn EF Core data mapping the easy way: owned entities, complex types, table splitting, value conversions, and JSON columns explained with simple analogies and code.

11 minEF Core · Entity Framework
beginner

5 EF Core Features You Need to Know (Beginner Friendly)

Learn 5 must-know EF Core features with simple examples: change tracking, AsNoTracking, eager loading, bulk ExecuteUpdate, and query filters.

15 minef-core · dotnet
intermediate

Scheduling Jobs with Quartz.NET and Database Persistence using EF Core Migrations

Learn Quartz.NET job scheduling in .NET 10 with database persistence. Set up AdoJobStore, create QRTZ tables via EF Core migrations, and survive restarts.

11 minQuartz.NET · EF Core
beginner

Top 10 Mistakes Developers Make in EF Core (and How to Fix Them)

The 10 most common EF Core mistakes that slow your app down — N+1 queries, missing AsNoTracking, ToList too early, lazy loading, and more — with simple fixes.

12 minEF Core · Entity Framework
beginner

Getting Started With pgvector in .NET for Simple Vector Search

Learn pgvector with .NET, Npgsql and EF Core to store embeddings and run simple vector search with cosine distance and HNSW indexes, step by step.

11 minpgvector · postgresql
intermediate

Offset vs Cursor Pagination in EF Core: A Simple, Complete Guide

Learn offset (Skip/Take) and cursor (keyset) pagination in EF Core with simple analogies, diagrams, real code, and clear advice on which one to pick and why.

11 minEF Core · pagination
intermediate

EF Core Bulk Data Retrieval: 5 Methods You Should Know

Learn 5 simple EF Core methods to read large datasets fast: AsNoTracking, projection, pagination, split queries, and streaming. With diagrams and clear code.

11 minEF Core · performance
intermediate

Using Stored Procedures and Functions With EF Core and PostgreSQL

A friendly, beginner guide to calling PostgreSQL stored procedures and functions from EF Core using FromSql, ExecuteSql, and keyless entities.

12 minef-core · postgresql
intermediate

Why You Don't Need a Repository in EF Core (For Most Apps)

EF Core already gives you a repository and unit of work. Learn why an extra repository layer is often just busywork, and when it actually helps.

12 minef-core · repository-pattern
beginner

How to Manage EF Core DbContext Lifetime: A Beginner's Guide

Learn how to manage EF Core DbContext lifetime safely. Understand scoped, transient, singleton, pooling, and DbContextFactory with simple examples and diagrams.

12 minEF Core · DbContext
beginner

Fast Document Database in .NET with Marten

Learn how Marten turns PostgreSQL into a fast document database for .NET. Save C# objects as JSON, query with LINQ, and keep full ACID safety.

13 minmarten · dotnet
intermediate

How to Implement Multitenancy in ASP.NET Core with EF Core

A simple, student-friendly guide to building multitenant apps in ASP.NET Core with EF Core using tenant resolution, global query filters, and per-tenant databases.

12 minef-core · dotnet
intermediate

Complete Guide to Transaction Isolation Levels in SQL

Learn SQL transaction isolation levels the easy way: dirty reads, non-repeatable reads, phantoms, snapshot, and serializable with simple diagrams and C# code.

14 minSQL · transactions