{"id":84336,"date":"2026-11-23T11:18:22","date_gmt":"2026-11-23T05:48:22","guid":{"rendered":"https:\/\/www.tothenew.com\/blog\/?p=84336"},"modified":"2026-11-25T14:09:37","modified_gmt":"2026-11-25T08:39:37","slug":"beyond-crud-building-better-net-apps-with-cqrs","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/","title":{"rendered":"Beyond CRUD: Building Better .NET Apps with CQRS"},"content":{"rendered":"<p><strong>CQRS and MediatR in .NET: A Practical Guide<\/strong><\/p>\n<p>As applications grow, maintaining business logic becomes increasingly challenging. What begins as a simple ASP.NET Core application with controllers, services, and repositories can gradually turn into a tightly coupled system where even small changes require modifications across multiple layers.<\/p>\n<p>One architectural approach that helps address this challenge is Command Query Responsibility Segregation (CQRS). When combined with MediatR, it provides a structured way to organize application logic, improve separation of concerns, and make code easier to maintain and test.<\/p>\n<p>In this article, we&#8217;ll explore how CQRS and MediatR work together in ASP.NET Core, examine practical implementation examples, and discuss when this approach makes sense.<\/p>\n<p><strong>Understanding CQRS<\/strong><br \/>\nCQRS is an architectural pattern that separates operations that modify application state from operations that retrieve data.<\/p>\n<p>It divides application responsibilities into two categories:<\/p>\n<ul style=\"list-style-type: disc;\">\n<li><strong>Commands<\/strong>: Operations that change application state, such as creating an order, updating a customer, or cancelling a transaction.<\/li>\n<li><strong>Queries<\/strong>: Operations that retrieve information without modifying application state.<br \/>\nIn a traditional service-based architecture, both operations often exist in the same service:<\/li>\n<\/ul>\n<p>public class OrderService<br \/>\n{<br \/>\npublic Task&lt;int&gt; CreateOrderAsync(<br \/>\nCreateOrderRequest request);<\/p>\n<p>public Task&lt;OrderDto?&gt; GetOrderAsync(int id);<br \/>\n}<br \/>\nAlthough this approach works well for smaller applications, large services can accumulate unrelated responsibilities as business requirements evolve.<\/p>\n<p>CQRS allows each operation to have its own request model and handler, making the responsibilities explicit.<\/p>\n<p>Importantly, CQRS does not require separate databases, microservices, or event sourcing. Read and write operations can share the same database while remaining logically separated.<\/p>\n<p><strong>What Is MediatR?<\/strong><br \/>\nMediatR is a .NET library that implements the mediator pattern. It allows application components to communicate through requests and handlers without directly depending on one another.<\/p>\n<p>Instead of a controller calling a service containing multiple business operations, it sends a request through MediatR.<\/p>\n<p>MediatR then dispatches that request to its corresponding handler.<\/p>\n<p>The typical request flow is:<\/p>\n<p><strong>API Controller \u2192 MediatR \u2192 Request Handler \u2192 Database<\/strong><\/p>\n<p>This approach provides several advantages:<\/p>\n<p>Reduced coupling between controllers and application logic.<br \/>\nClear separation of individual business operations.<br \/>\nEasier unit testing of handlers.<br \/>\nCentralized cross-cutting concerns through pipeline behaviors.<br \/>\nMediatR does not implement CQRS automatically. Rather, it provides useful building blocks for organizing commands and queries.<\/p>\n<p><strong>Implementing CQRS with MediatR<\/strong><br \/>\nLet&#8217;s consider a simple Order Management application built using ASP.NET Core and Entity Framework Core.<\/p>\n<p>We&#8217;ll implement two operations:<\/p>\n<p>Create a new order using a command.<br \/>\nRetrieve an existing order using a query.<\/p>\n<p><strong>Step 1: Create a Command<\/strong><br \/>\nA command represents an intention to modify application state.<\/p>\n<p>using MediatR;<\/p>\n<p>public record CreateOrderCommand(<br \/>\nint CustomerId,<br \/>\ndecimal Amount) : IRequest&lt;int&gt;;<br \/>\nHere, IRequest&lt;int&gt; indicates that the command expects an integer response representing the newly created order ID.<\/p>\n<p><strong>Step 2: Implement the Command Handler<\/strong><br \/>\nEach command has a dedicated handler responsible for executing the operation.<\/p>\n<p>public class CreateOrderHandler<br \/>\n: IRequestHandler&lt;CreateOrderCommand, int&gt;<br \/>\n{<br \/>\nprivate readonly AppDbContext _context;<\/p>\n<p>public CreateOrderHandler(AppDbContext context)<br \/>\n{<br \/>\n_context = context;<br \/>\n}<\/p>\n<p>public async Task&lt;int&gt; Handle(<br \/>\nCreateOrderCommand request,<br \/>\nCancellationToken cancellationToken)<br \/>\n{<br \/>\nvar order = new Order<br \/>\n{<br \/>\nCustomerId = request.CustomerId,<br \/>\nAmount = request.Amount<br \/>\n};<\/p>\n<p>_context.Orders.Add(order);<\/p>\n<p>await _context.SaveChangesAsync(<br \/>\ncancellationToken);<\/p>\n<p>return order.Id;<br \/>\n}<br \/>\n}<br \/>\nThe handler focuses exclusively on creating an order.<\/p>\n<p>Validation, authorization, and other cross-cutting concerns can be handled separately, allowing the business operation to remain focused.<\/p>\n<p><strong>Step 3: Create a Query<\/strong><br \/>\nQueries retrieve data without modifying application state.<\/p>\n<p>public record GetOrderByIdQuery(int Id)<br \/>\n: IRequest&lt;OrderDto?&gt;;<br \/>\nThe corresponding handler retrieves the requested order:<\/p>\n<p>public class GetOrderByIdHandler<br \/>\n: IRequestHandler&lt;GetOrderByIdQuery, OrderDto?&gt;<br \/>\n{<br \/>\nprivate readonly AppDbContext _context;<\/p>\n<p>public GetOrderByIdHandler(AppDbContext context)<br \/>\n{<br \/>\n_context = context;<br \/>\n}<\/p>\n<p>public async Task&lt;OrderDto?&gt; Handle(<br \/>\nGetOrderByIdQuery request,<br \/>\nCancellationToken cancellationToken)<br \/>\n{<br \/>\nreturn await _context.Orders<br \/>\n.AsNoTracking()<br \/>\n.Where(o =&gt; o.Id == request.Id)<br \/>\n.Select(o =&gt; new OrderDto(<br \/>\no.Id,<br \/>\no.CustomerId,<br \/>\no.Amount))<br \/>\n.FirstOrDefaultAsync(cancellationToken);<br \/>\n}<br \/>\n}<br \/>\nUsing AsNoTracking() avoids unnecessary change tracking for read-only operations.<\/p>\n<p>Projecting directly into a DTO also prevents loading entity properties that the response does not require.<\/p>\n<p><strong>Step 4: Connect MediatR to ASP.NET Core<\/strong><br \/>\nRegister MediatR in Program.cs:<\/p>\n<p>builder.Services.AddMediatR(cfg =&gt;<br \/>\ncfg.RegisterServicesFromAssembly(<br \/>\ntypeof(CreateOrderCommand).Assembly));<br \/>\nNow the controller can dispatch requests through ISender:<\/p>\n<p>[ApiController]<br \/>\n[Route(&#8220;api\/orders&#8221;)]<br \/>\npublic class OrdersController : ControllerBase<br \/>\n{<br \/>\nprivate readonly ISender _sender;<\/p>\n<p>public OrdersController(ISender sender)<br \/>\n{<br \/>\n_sender = sender;<br \/>\n}<\/p>\n<p>[HttpPost]<br \/>\npublic async Task&lt;IActionResult&gt; Create(<br \/>\nCreateOrderCommand command,<br \/>\nCancellationToken cancellationToken)<br \/>\n{<br \/>\nvar id = await _sender.Send(<br \/>\ncommand, cancellationToken);<\/p>\n<p>return CreatedAtAction(<br \/>\nnameof(GetById), new { id }, id);<br \/>\n}<\/p>\n<p>[HttpGet(&#8220;{id:int}&#8221;)]<br \/>\npublic async Task&lt;IActionResult&gt; GetById(<br \/>\nint id,<br \/>\nCancellationToken cancellationToken)<br \/>\n{<br \/>\nvar order = await _sender.Send(<br \/>\nnew GetOrderByIdQuery(id),<br \/>\ncancellationToken);<\/p>\n<p>return order is null<br \/>\n? NotFound()<br \/>\n: Ok(order);<br \/>\n}<br \/>\n}<br \/>\nThe controller no longer needs to know how orders are created or retrieved. Its responsibility is limited to handling HTTP requests and responses.<\/p>\n<p>For this example, assume that Order, OrderDto, and AppDbContext are already defined.<\/p>\n<p><strong>Using Pipeline Behaviors for Cross-Cutting Concerns<\/strong><br \/>\nOne of MediatR&#8217;s most useful capabilities is its support for pipeline behaviors.<\/p>\n<p>In enterprise applications, operations frequently require common functionality such as:<\/p>\n<p>Request validation.<br \/>\nStructured logging.<br \/>\nPerformance monitoring.<br \/>\nTransaction management.<br \/>\nException handling.<br \/>\nInstead of repeating this logic inside every handler, pipeline behaviors allow it to be implemented centrally.<\/p>\n<p>For example, a logging behavior can record request execution:<\/p>\n<p>public class LoggingBehavior&lt;TRequest, TResponse&gt;<br \/>\n: IPipelineBehavior&lt;TRequest, TResponse&gt;<br \/>\nwhere TRequest : notnull<br \/>\n{<br \/>\nprivate readonly ILogger&lt;LoggingBehavior<br \/>\n&lt;TRequest, TResponse&gt;&gt; _logger;<\/p>\n<p>public LoggingBehavior(<br \/>\nILogger&lt;LoggingBehavior&lt;TRequest, TResponse&gt;&gt;<br \/>\nlogger)<br \/>\n{<br \/>\n_logger = logger;<br \/>\n}<\/p>\n<p>public async Task&lt;TResponse&gt; Handle(<br \/>\nTRequest request,<br \/>\nRequestHandlerDelegate&lt;TResponse&gt; next,<br \/>\nCancellationToken cancellationToken)<br \/>\n{<br \/>\n_logger.LogInformation(<br \/>\n&#8220;Handling {RequestName}&#8221;,<br \/>\ntypeof(TRequest).Name);<\/p>\n<p>var response = await next(cancellationToken);<\/p>\n<p>_logger.LogInformation(<br \/>\n&#8220;Completed {RequestName}&#8221;,<br \/>\ntypeof(TRequest).Name);<\/p>\n<p>return response;<br \/>\n}<br \/>\n}<br \/>\nRegister the behavior through MediatR configuration:<\/p>\n<p>builder.Services.AddMediatR(cfg =&gt;<br \/>\n{<br \/>\ncfg.RegisterServicesFromAssembly(<br \/>\ntypeof(CreateOrderCommand).Assembly);<\/p>\n<p>cfg.AddOpenBehavior(<br \/>\ntypeof(LoggingBehavior&lt;,&gt;));<br \/>\n});<br \/>\nThis ensures consistent logging across requests without duplicating code in individual handlers.<\/p>\n<p>In production applications, sensitive request data should not be logged indiscriminately.<\/p>\n<p><strong>Real-World Best Practices<\/strong><br \/>\nImplementing CQRS successfully requires more than creating separate command and query classes.<\/p>\n<p><strong>1. Keep handlers focused<\/strong><\/p>\n<p>Each handler should represent a clear business operation. Avoid creating handlers that perform multiple unrelated responsibilities.<\/p>\n<p><strong>2. Optimize reads independently<\/strong><\/p>\n<p>Queries often benefit from lightweight DTO projections, AsNoTracking(), pagination, and appropriate database indexes.<\/p>\n<p><strong>3. Validate before executing commands<\/strong><\/p>\n<p>Use validation pipelines to reject invalid requests before they reach business logic. Business invariants must still be enforced where appropriate.<\/p>\n<p><strong>4. Manage transactions carefully<\/strong><\/p>\n<p>Commands involving multiple database changes may require explicit transaction boundaries. Avoid assuming every command automatically needs its own transaction.<\/p>\n<p><strong>5. Test business behavior<\/strong><\/p>\n<p>Unit-test handlers independently, but also use integration tests to verify database interactions, transactions, and pipeline configuration.<\/p>\n<p><strong>When Should You Avoid CQRS?<\/strong><br \/>\nCQRS is not always the right choice.<\/p>\n<p>For small CRUD applications with straightforward business rules, introducing commands, queries, handlers, and pipeline behaviors can increase complexity without delivering meaningful benefits.<\/p>\n<p>CQRS becomes more valuable when:<\/p>\n<p>Business operations have distinct responsibilities.<br \/>\nRead and write requirements differ significantly.<br \/>\nApplication complexity continues to grow.<br \/>\nMultiple developers work on independent features.<br \/>\nCross-cutting concerns require consistent implementation.<br \/>\nThe goal should be maintainability, not architectural complexity for its own sake.<\/p>\n<p><strong>Conclusion<\/strong><br \/>\nCQRS and MediatR can provide a structured approach to building maintainable ASP.NET Core applications. By separating commands from queries and keeping handlers focused, teams can organize complex business logic more effectively.<\/p>\n<p>However, successful architecture is about choosing the right level of abstraction. CQRS should solve real problems rather than become a mandatory pattern for every project.<\/p>\n<p><strong>Are you using CQRS and MediatR in your .NET applications?<\/strong> Share your experiences, challenges, and lessons learned in the comments. Exploring different implementation approaches can help teams make better architectural decisions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CQRS and MediatR in .NET: A Practical Guide As applications grow, maintaining business logic becomes increasingly challenging. What begins as a simple ASP.NET Core application with controllers, services, and repositories can gradually turn into a tightly coupled system where even small changes require modifications across multiple layers. One architectural approach that helps address this challenge [&hellip;]<\/p>\n","protected":false},"author":2399,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0,"footnotes":""},"categories":[5867],"tags":[9111,9114,9112,9115,9113,5931],"class_list":["post-84336","post","type-post","status-publish","format-standard","hentry","category-net","tag-aspnetcore","tag-cleanarchitecture","tag-cqrs","tag-entityframeworkcore","tag-mediatr","tag-softwarearchitecture"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"CQRS and MediatR in .NET: A Practical Guide As applications grow, maintaining business logic becomes increasingly challenging. What begins as a simple ASP.NET Core application with controllers, services, and repositories can gradually turn into a tightly coupled system where even small changes require modifications across multiple layers. One architectural approach that helps address this challenge\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Harjot Singh\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Beyond CRUD: Building Better .NET Apps with CQRS | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"CQRS and MediatR in .NET: A Practical Guide As applications grow, maintaining business logic becomes increasingly challenging. What begins as a simple ASP.NET Core application with controllers, services, and repositories can gradually turn into a tightly coupled system where even small changes require modifications across multiple layers. One architectural approach that helps address this challenge\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Beyond CRUD: Building Better .NET Apps with CQRS | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"CQRS and MediatR in .NET: A Practical Guide As applications grow, maintaining business logic becomes increasingly challenging. What begins as a simple ASP.NET Core application with controllers, services, and repositories can gradually turn into a tightly coupled system where even small changes require modifications across multiple layers. One architectural approach that helps address this challenge\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/beyond-crud-building-better-net-apps-with-cqrs\\\/#article\",\"name\":\"Beyond CRUD: Building Better .NET Apps with CQRS | TO THE NEW Blog\",\"headline\":\"Beyond CRUD: Building Better .NET Apps with CQRS\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/harjot-singh\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2026-11-23T11:18:22+05:30\",\"dateModified\":\"2026-11-25T14:09:37+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/beyond-crud-building-better-net-apps-with-cqrs\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/beyond-crud-building-better-net-apps-with-cqrs\\\/#webpage\"},\"articleSection\":\".NET, ASPNETCore, CleanArchitecture, CQRS, EntityFrameworkCore, MediatR, SoftwareArchitecture\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/beyond-crud-building-better-net-apps-with-cqrs\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/net\\\/#listItem\",\"name\":\".NET\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/net\\\/#listItem\",\"position\":2,\"name\":\".NET\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/net\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/beyond-crud-building-better-net-apps-with-cqrs\\\/#listItem\",\"name\":\"Beyond CRUD: Building Better .NET Apps with CQRS\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/beyond-crud-building-better-net-apps-with-cqrs\\\/#listItem\",\"position\":3,\"name\":\"Beyond CRUD: Building Better .NET Apps with CQRS\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/net\\\/#listItem\",\"name\":\".NET\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/harjot-singh\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/harjot-singh\\\/\",\"name\":\"Harjot Singh\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/beyond-crud-building-better-net-apps-with-cqrs\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c0b131ac0145a3f419e29e799a12f8475a101b438e87575a7c96098b23e7cd9d?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Harjot Singh\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/beyond-crud-building-better-net-apps-with-cqrs\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/beyond-crud-building-better-net-apps-with-cqrs\\\/\",\"name\":\"Beyond CRUD: Building Better .NET Apps with CQRS | TO THE NEW Blog\",\"description\":\"CQRS and MediatR in .NET: A Practical Guide As applications grow, maintaining business logic becomes increasingly challenging. What begins as a simple ASP.NET Core application with controllers, services, and repositories can gradually turn into a tightly coupled system where even small changes require modifications across multiple layers. One architectural approach that helps address this challenge\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/beyond-crud-building-better-net-apps-with-cqrs\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/harjot-singh\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/harjot-singh\\\/#author\"},\"datePublished\":\"2026-11-23T11:18:22+05:30\",\"dateModified\":\"2026-11-25T14:09:37+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Beyond CRUD: Building Better .NET Apps with CQRS | TO THE NEW Blog","description":"CQRS and MediatR in .NET: A Practical Guide As applications grow, maintaining business logic becomes increasingly challenging. What begins as a simple ASP.NET Core application with controllers, services, and repositories can gradually turn into a tightly coupled system where even small changes require modifications across multiple layers. One architectural approach that helps address this challenge","canonical_url":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/#article","name":"Beyond CRUD: Building Better .NET Apps with CQRS | TO THE NEW Blog","headline":"Beyond CRUD: Building Better .NET Apps with CQRS","author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/harjot-singh\/#author"},"publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"},"datePublished":"2026-11-23T11:18:22+05:30","dateModified":"2026-11-25T14:09:37+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/#webpage"},"isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/#webpage"},"articleSection":".NET, ASPNETCore, CleanArchitecture, CQRS, EntityFrameworkCore, MediatR, SoftwareArchitecture"},{"@type":"BreadcrumbList","@id":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.tothenew.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/net\/#listItem","name":".NET"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/net\/#listItem","position":2,"name":".NET","item":"https:\/\/www.tothenew.com\/blog\/category\/net\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/#listItem","name":"Beyond CRUD: Building Better .NET Apps with CQRS"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/#listItem","position":3,"name":"Beyond CRUD: Building Better .NET Apps with CQRS","previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/net\/#listItem","name":".NET"}}]},{"@type":"Organization","@id":"https:\/\/www.tothenew.com\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/www.tothenew.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.tothenew.com\/blog\/author\/harjot-singh\/#author","url":"https:\/\/www.tothenew.com\/blog\/author\/harjot-singh\/","name":"Harjot Singh","image":{"@type":"ImageObject","@id":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/c0b131ac0145a3f419e29e799a12f8475a101b438e87575a7c96098b23e7cd9d?s=96&d=mm&r=g","width":96,"height":96,"caption":"Harjot Singh"}},{"@type":"WebPage","@id":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/#webpage","url":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/","name":"Beyond CRUD: Building Better .NET Apps with CQRS | TO THE NEW Blog","description":"CQRS and MediatR in .NET: A Practical Guide As applications grow, maintaining business logic becomes increasingly challenging. What begins as a simple ASP.NET Core application with controllers, services, and repositories can gradually turn into a tightly coupled system where even small changes require modifications across multiple layers. One architectural approach that helps address this challenge","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/#breadcrumblist"},"author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/harjot-singh\/#author"},"creator":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/harjot-singh\/#author"},"datePublished":"2026-11-23T11:18:22+05:30","dateModified":"2026-11-25T14:09:37+05:30"},{"@type":"WebSite","@id":"https:\/\/www.tothenew.com\/blog\/#website","url":"https:\/\/www.tothenew.com\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Beyond CRUD: Building Better .NET Apps with CQRS | TO THE NEW Blog","og:description":"CQRS and MediatR in .NET: A Practical Guide As applications grow, maintaining business logic becomes increasingly challenging. What begins as a simple ASP.NET Core application with controllers, services, and repositories can gradually turn into a tightly coupled system where even small changes require modifications across multiple layers. One architectural approach that helps address this challenge","og:url":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/","og:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Beyond CRUD: Building Better .NET Apps with CQRS | TO THE NEW Blog","twitter:description":"CQRS and MediatR in .NET: A Practical Guide As applications grow, maintaining business logic becomes increasingly challenging. What begins as a simple ASP.NET Core application with controllers, services, and repositories can gradually turn into a tightly coupled system where even small changes require modifications across multiple layers. One architectural approach that helps address this challenge","twitter:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"84336","title":null,"description":null,"keywords":null,"keyphrases":{"focus":{"keyphrase":"","score":0,"analysis":{"keyphraseInTitle":{"score":0,"maxScore":9,"error":1}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"limit_modified_date":false,"created":"2026-11-23 05:47:59","updated":"2026-11-25 08:39:39","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":{"faqs":[],"keyPoints":[],"schemas":[],"titles":[],"descriptions":[],"socialPosts":{"email":{"subject":"","preview":"","content":""},"linkedin":[],"twitter":[],"facebook":[],"instagram":[]}},"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\/category\/net\/\" title=\".NET\">.NET<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tBeyond CRUD: Building Better .NET Apps with CQRS\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.tothenew.com\/blog"},{"label":".NET","link":"https:\/\/www.tothenew.com\/blog\/category\/net\/"},{"label":"Beyond CRUD: Building Better .NET Apps with CQRS","link":"https:\/\/www.tothenew.com\/blog\/beyond-crud-building-better-net-apps-with-cqrs\/"}],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/84336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/2399"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=84336"}],"version-history":[{"count":4,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/84336\/revisions"}],"predecessor-version":[{"id":84369,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/84336\/revisions\/84369"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=84336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=84336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=84336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}