Skip to content

Blog

Dynamic Connection Strings in EF Core 9 Minimal APIs

Altering a DbContext Connection at Runtime

In Entity Framework Core (including EF Core 9.x), the database connection is normally configured when the DbContext is constructed, and it isn’t intended to be changed afterward. Once a DbContext is injected (e.g. via DI in a minimal API), its DbContextOptions (including the connection string) are essentially fixed. There is no built-in method to reconfigure the context’s connection string after it’s been created in the DI container. In other words, you cannot directly “swap out” the connection string of an existing context instance once it’s been configured.

Evaluating MediatR in Modern .NET (8, 9, 10) Applications

Introduction and Background

MediatR is a popular .NET library that implements the Mediator pattern for in-process messaging. It allows decoupling of request senders from their handlers by routing messages (requests/commands/queries) through a central mediator. Over the years it has become a staple in many “Clean Architecture” templates and CQRS-style projects, with over 286 million NuGet downloads as of 2025 (MediatR and MassTransit Going Commercial: What This Means For You). MediatR provides a simple request/response API and supports publish/subscribe for in-memory notifications, along with a pipeline behavior feature that enables plugging in cross-cutting concerns (like logging, validation, etc.) around those requests.

However, the landscape has changed in recent .NET versions (8 and beyond). The .NET platform now offers native features (such as minimal API endpoint filters, improved middleware, and powerful DI patterns) that cover many use cases MediatR was traditionally used for. Additionally, MediatR’s licensing has evolved – it is transitioning from a free OSS tool to a commercial (paid) product, raising questions about relying on it for core infrastructure (AutoMapper and MediatR Going Commercial) (MediatR and MassTransit Going Commercial: What This Means For You). This article provides a comprehensive evaluation of using MediatR in modern .NET applications, comparing its benefits and drawbacks to native alternatives, and offering guidance on when (if ever) it remains the right choice.

Modeller DSL Parser: Your Gateway to Flexible Parsing in C

Welcome to the world of parsing with Modeller DSL. This lightweight, high-speed, and adaptable parsing library for C# empowers you to construct parsers with ease.

Getting Started with Modeller DSL Parser

Modeller.DslParser is a parser combinator library, offering a high-level, declarative approach to crafting parsers. These parsers resemble a high-level specification of a language's grammar, yet they are expressed within a general-purpose programming language, requiring no special tools for producing executable code. Parser combinators offer enhanced capabilities compared to regular expressions, as they can handle a broader range of languages, all while being simpler and more user-friendly than parser generators like ANTLR.

Avoiding flaky tests with TimeProvider and ITimer

This is an extract from Andrew Lock's blog. Jump over and check out his work, he is a very talented individual and has some awesome posts.

What's the problem with the existing APIs?

Even if you're new to C#, you have likely needed to get "the current time" at some point. The default way to do that is to use the DateTime.UtcNow or DateTimeOffset.UtcNow static properties. You can call these properties from anywhere in your code so they're an easy thing to reach for wherever you are.

Utilizing MassTransit in .NET Core with RabbitMQ

Are you in search of an open-source distributed application framework designed for .NET, one that streamlines the development of message-based applications? MassTransit is the solution you've been seeking. It offers a straightforward yet robust means of constructing distributed systems using message-based architectural paradigms, including event-driven, publish/subscribe, and request/response patterns.

In the next few posts, I will explain my thoughts and guide you through the process of harnessing MassTransit within a .NET-based ASP.NET Core Web API.

By the conclusion of this series, you will be well-equipped to establish and configure a producer and consumer message service for RabbitMQ. We will also delve into some advanced RabbitMQ use cases and explore key concepts essential to effectively work with distributed solutions.

Project Directory Structures

Various methods exist for organizing a project's directory structure, but I have a particular preference. Prior to delving into that, let's examine the conventional approaches often suggested by templates and demoware and why they may not be the most advantageous choice.