Skip to content

.NET Before vs After the AI Era

Core Concept LearningJuly 1, 20266 min readUpdated July 21, 2026

Artificial intelligence is not here to replace .NET developers. It is here to extend what they can build. The fundamentals you already know — services, APIs, data access, validation — still matter. What changes is how you compose them. What Is Agentic AI? defines the bounded runtime behind the agent examples.

Instead of shipping systems that only move data, you design systems that understand context, reason over it, and take action. Twelve practical shifts turn a traditional .NET codebase into a production-ready AI system. Framework and product examples are current as of July 2026; APIs and defaults may change. For tool and remote-agent boundaries, use MCP vs A2A vs ACP.

Traditional stack vs AI-era stack
Traditional stack vs AI-era stack

From Repository Calls to AI Agents

A repository gives you a record. That is useful, but modern applications often need more than raw fields — they need interpretation. An AI agent wraps your data access with reasoning. Rather than returning a customer entity and pushing interpretation to the UI, the agent can summarize behavior, flag churn risk, and highlight next steps in one call.

Quick reference

  • Keep repositories for CRUD; wrap them inside agents for interpretation and summarization.
  • Return structured agent output (summary, risk score, suggested actions) — not raw LLM text.
  • Log which data the agent accessed for audit and debugging.
Traditional approach
1var customer = await _customerRepository.GetById(id);
Illustrative pseudo-code — agent wrapper
1var summary = await _customerAgent.ExecuteAsync(2  "Summarize this customer profile and identify churn risk."3);

Remember this

Stop thinking only in terms of data retrieval. Start thinking in terms of intelligence retrieval.

From SQL LIKE to Vector Search

Keyword search breaks the moment users phrase questions differently from your database content. Vector search matches meaning, not just characters. Embeddings let users ask natural questions like “How can I reduce claim rejection?” and still get relevant policy or document results.

Quick reference

  • Chunk documents with overlap so answers are not cut mid-sentence.
  • Store embeddings in a dedicated vector store — do not query vectors in SQL Server unless you must.
  • Re-rank top-k results before sending them to the LLM for better precision.
Traditional approach
1SELECT * FROM Documents2WHERE Content LIKE '%health insurance%';
Illustrative pseudo-code — vector client
1var results = await _vectorDb.SearchAsync(2  "How can I reduce claim rejection?"3);

Remember this

Semantic search turns static document stores into knowledge bases users can actually talk to.

From REST APIs to MCP Tools

REST endpoints are powerful, but they are built for developers who already know your API surface. MCP (Model Context Protocol) exposes capabilities as tools that agents can discover and invoke. Your backend stays the source of truth, but the interaction model becomes agent-friendly instead of human-integration-friendly.

MCP exposes backend capabilities as tools an agent can call
MCP exposes backend capabilities as tools an agent can call

Quick reference

  • Expose each capability as a named tool with a JSON schema for parameters.
  • Keep REST APIs for human integrations; add MCP for agent-driven workflows.
  • Validate tool inputs server-side — agents can hallucinate argument shapes.
Traditional approach
1var response = await httpClient2  .GetAsync("/api/customers/123");
Illustrative pseudo-code — MCP client
1var result = await _mcpClient.CallToolAsync(2  "GetCustomers",3  new { customerId = 123 }4);

Remember this

Design backend capabilities as tools, not just HTTP endpoints.

From Business Rules to Prompt-Driven Agents

Deterministic rules remain the authority for compliance limits, permissions, and approvals. A model can summarize evidence or recommend a route when policy language is nuanced, but its output should not become an approval decision until authorization checks, measured eval thresholds, and a recoverable human-review path are in place.

Quick reference

  • Authorize the caller and allowed action before exposing order data or accepting a recommendation.
  • Require structured output (recommendation, reasons, uncertainty); deterministic policy or a human owns the final approval.
  • Version prompts and ship only above a documented golden-set threshold, with abstention and manual recovery below it.
Traditional approach
1if (order.Amount > 100000)2{3    order.RequiresApproval = true;4}
Illustrative pseudo-code — recommendation only
1var decision = await _approvalAgent.ExecuteAsync(2  "Review this order. Decide if approval is required and explain why."3);

Remember this

Use models to support judgment only when policy enforcement and final approval remain controlled and recoverable.

From CRUD Reads to RAG Questions

Fetching a policy by ID assumes the user already knows what to look for and how to read it. Retrieval-Augmented Generation (RAG) lets users ask direct questions against your documents and get grounded answers. The system retrieves relevant chunks first, then generates a response based on real source material.

RAG retrieves grounding chunks before the LLM generates an answer
RAG retrieves grounding chunks before the LLM generates an answer

Quick reference

  • Retrieve first, generate second — never let the LLM answer without source chunks.
  • Cite document IDs or page numbers in responses for trust and verification.
  • Refresh embeddings when source documents change.
Traditional approach
1var policy = await _policyRepository.GetById(id);
Illustrative pseudo-code — RAG wrapper
1var answer = await _ragPipeline.AskAsync(2  "Does this policy cover cataract surgery?"3);

Remember this

Turn document storage into question answering with RAG.

From Service Layers to Autonomous Agents

Service classes are the right place for known workflows, authorization, invariants, and transactions. An agent may propose or select among bounded next steps when context changes the route, but deterministic code must validate every tool call and contain failures; the agent does not replace the workflow's safety boundary.

Quick reference

  • Authorize each allowed tool and resource; never inherit the model's claimed identity or scope.
  • Keep domain validation and transaction boundaries in code; require eval thresholds before enabling autonomous routing.
  • Make retries idempotent, cap steps/cost, isolate side effects, and persist enough state for human recovery.
Traditional approach
1public async Task ProcessClaim(ClaimRequest request)2{3    var claim = await _repository.GetById(request.Id);4    // validate, transform, persist...5    await _repository.Update(claim);6}
Illustrative pseudo-code — bounded agent call
1public async Task ProcessClaim(ClaimRequest request)2{3    await _claimAgent.ExecuteAsync(request);4}

Remember this

Agents may choose among bounded workflow steps; code retains authorization, validation, transactions, and recovery.

From Cache Keys to Semantic Memory

Caching is fast when you already know the key. Semantic memory is useful when you need relevant prior context without naming it exactly. Instead of storing one blob under one key, you store knowledge in a way that can be recalled by meaning — previous rejections, customer preferences, or recurring failure patterns.

Quick reference

  • Store memories as embeddings with metadata (user, session, timestamp).
  • Retrieve top-k relevant memories per query — do not inject full history.
  • Expire or summarize old memories to control cost and relevance.
Traditional approach
1var data = await _redis.GetAsync(key);
Illustrative pseudo-code — semantic memory
1var context = await _memory.GetRelevantContextAsync(2  "claim rejection reasons"3);

Remember this

Memory for AI systems should be contextual, not just key-based.

From Application Logs to AI Observability

Standard logging tells you that something happened. AI observability tells you how an agent reasoned through a task — which tools it called, what prompt it used, how long inference took, and where quality broke down. Tools like LangSmith and OpenTelemetry help you trace agent behavior the same way you trace distributed requests.

Quick reference

  • Trace prompt, model, tokens, latency, and each tool call in one span tree.
  • Alert on cost and quality regressions, not only HTTP 500s.
  • Sample traces in production — full capture is expensive at scale.
Traditional approach
1_logger.LogInformation("Claim submitted");
Illustrative pseudo-code — tracing wrappers
1await _langSmith.TraceAsync(async () =>2{3    await _openTelemetry.CaptureAITrace();4});

Remember this

If you cannot observe agent behavior, you cannot trust it in production.

From Background Jobs to AI Workflows

A background service is ideal for repetitive scheduled work. AI workflows are better when each run may involve different steps — load data, analyze, summarize, notify, escalate. State graphs let you define these stages explicitly while still allowing agents to handle the intelligent parts.

Quick reference

  • Model each stage explicitly so failures can resume from the last good step.
  • Use queues for long-running AI steps — do not block HTTP requests.
  • Persist workflow state so retries do not duplicate side effects.
Traditional approach
1public class ClaimWorker : BackgroundService2{3    protected override async Task ExecuteAsync(4        CancellationToken stoppingToken)5    {6        while (!stoppingToken.IsCancellationRequested)7        {8            await ProcessPendingClaims();9            await Task.Delay(TimeSpan.FromMinutes(5), stoppingToken);10        }11    }12}
Illustrative pseudo-code — workflow library
1var workflow = new StateGraphBuilder()2    .AddStep("Load Data", LoadClaims)3    .AddStep("Process", _claimAgent.ExecuteAsync)4    .AddStep("Summarize", GenerateReport)5    .Build();

Remember this

Model AI pipelines as workflows, not just timers and loops.

From Controllers to AI Copilots

Controllers expose rigid contracts: DTO in, DTO out. Copilots let users describe intent in natural language. That does not replace APIs for system-to-system communication, but it dramatically improves human-facing experiences for operations teams, support staff, and internal tools.

A copilot translates intent into an existing, unchanged service call
A copilot translates intent into an existing, unchanged service call

Quick reference

  • Copilots translate intent to existing service calls — do not bypass validation.
  • Confirm destructive actions with the user before executing tools.
  • Show what the copilot understood before running create/update operations.
Traditional approach
1[HttpPost("orders")]2public async Task<IActionResult> CreateOrder(CreateOrderDto dto)3{4    var order = await _orderService.CreateAsync(dto);5    return Ok(order);6}
Illustrative pseudo-code — copilot wrapper
1var reply = await _copilot.ChatAsync(2  "Create an order for Rahul with the premium health plan."3);

Remember this

Natural language interfaces are a new layer on top of your existing domain services.

From DTO Validation to AI Validation

Field validators enforce shape, invariants, and policy checks that must be deterministic. A model can flag ambiguous intent, missing context, or contradictions across a document, but that output is advisory until measured against a representative eval set and routed to a deterministic rule or human reviewer.

Quick reference

  • Keep FluentValidation and authorization for enforceable rules; use AI to surface candidates for review.
  • Return structured findings (field, evidence, severity) and validate the schema before downstream use.
  • Set an eval-backed acceptance threshold; abstain or route to a human on uncertainty, model failure, or conflicting evidence.
Traditional approach
1RuleFor(x => x.Amount).NotEmpty().GreaterThan(0);2RuleFor(x => x.CustomerId).NotEmpty();
Illustrative pseudo-code — advisory review
1var result = await _validatorAgent.ExecuteAsync(document);2// Evaluates intent and business rules across the full document

Remember this

Use AI as an advisory reviewer for contextual ambiguity, never as the sole enforcement boundary.

From Microservices to AI Systems

Classic microservice architecture flows through layers: controller, service, repository, database. AI system architecture flows through intelligence: agent, MCP server, vector database, LLM, and tools/APIs. The shift is not “delete your services.” It is “place an intelligent coordination layer above them.”

AI-era stack: an agent coordinates tools above your existing services
AI-era stack: an agent coordinates tools above your existing services

Quick reference

  • Microservices remain the data and transaction layer; agents sit above them.
  • Add vector stores and tool gateways as first-class infrastructure components.
  • Design for observability and cost control from the first AI feature.
Traditional stack
1Controller → Service → Repository → Database
Conceptual architecture — not literal call order
1AI Agent → MCP Server → Vector DB → LLM → Tools & APIs

Remember this

Architect for understanding and action, not only for data processing.

Key takeaway

The useful shift is not replacing repositories, policies, or validators with a model. It is placing one bounded AI adapter above deterministic code, then proving that the old contract still holds when the model succeeds, abstains, times out, or proposes an unauthorized action.

Practice (30 min, before → after): run dotnet new xunit -n AiBoundaryLab. First write a deterministic ApprovalPolicy.RequiresReview(amount) test where 100001m returns true. Then wrap that policy with a fake IAiReviewer that returns a recommendation plus evidence, while the policy remains final. Add three tests: a normal recommendation preserves the policy result; a timeout returns NeedsHumanReview; and a recommendation to auto-approve 100001m is denied. Run dotnet test. Pass only when all three tests are green, the timeout is bounded, and replacing the reviewer with a throwing fake cannot bypass the original rule.

Share:

Related Articles

AI agents rarely work alone. They read files, query databases, call business APIs, and sometimes delegate work to other

Read

Connecting AI agents (such as ChatGPT, Claude Code, and Gemini CLI) to external tools, enterprise microservices, and dat

Read

The Model Context Protocol (MCP) is the open standard for connecting AI agents to external data sources, enterprise data

Read

Keep learning

Follow a structured path or browse all courses to go deeper.