Best AI Coding Tools for .NET in 2026: Which One Actually Gets Minimal APIs?

We tested Cursor, Claude Code, Copilot, Windsurf, and Aider on real ASP.NET Core 9 projects — minimal APIs, source generators, AOT, EF Core 9, and Aspire. Here's which AI coding tools actually write C# you'd ship in 2026.

By vibecodemeta 9 min read
dotnet csharp aspnet-core ai-coding tools comparison vibe-coding

.NET should be the easiest win for AI coding tools. A 25-year corpus of C#, the most rigorously typed mainstream language short of Rust, and a first-party documentation site so thorough it reads like a textbook. And yet in 2026 most AI tools still hand back ASP.NET code that looks like a 2019 tutorial: Startup.cs with ConfigureServices, controllers inheriting from ControllerBase for a three-line endpoint, HttpClient constructed manually instead of IHttpClientFactory, and zero awareness that .NET 9 made minimal APIs, source generators, and native AOT the default enterprise path. C# devs feel it on every prompt — the AI writes code that compiles, passes tests, and gets quietly rewritten before it hits main.

We spent a week running every major AI coding tool against the same three ASP.NET Core 9 projects: a minimal-API service with source-generated JSON and OpenAPI, a native-AOT CLI tool, and an EF Core 9 data layer wired into .NET Aspire. Same prompts, same repos, same Directory.Packages.props. Here’s which tools actually write idiomatic modern .NET in 2026.

The 30-Second Verdict

If you want the spoiler: Claude Code and Cursor tied for first on .NET 9, with Claude Code pulling ahead on anything touching source generators or native AOT, and Cursor winning on day-to-day EF Core and Aspire orchestration. Copilot is the safest default if you already live in Visual Studio. Windsurf writes the cleanest minimal-API code of anything we tested. Aider is for the C# diehards who want to review every diff by hand.

Full breakdown below.

How We Tested

Three reference projects, all on .NET 9 / C# 13:

  1. Minimal-API service — a product catalog API with source-generated System.Text.Json contexts, source-generated OpenAPI, request validation via FluentValidation, output caching, and rate limiting. The prompt: “Add a new /products/{id}/variants endpoint with validation, caching, and OpenAPI docs, using minimal APIs and source generators where possible.”

  2. Native-AOT CLI — a dotnet tool-packable CLI using System.CommandLine, compiled with PublishAot=true. The prompt: “Add a new sync subcommand that streams JSON over HTTP and writes to SQLite, AOT-safe, no reflection.”

  3. EF Core 9 + Aspire — a multi-service solution with an API, a worker, Postgres, Redis, and a dashboard, all orchestrated via .NET Aspire. The prompt: “Add a new background worker that consumes from Redis Streams and writes aggregates to Postgres via EF Core 9, wired into the existing Aspire AppHost.”

Every tool got the same prompts, same repos, and the same three rounds of follow-up. We scored on idiomatic .NET 9, AOT compatibility, build success, and whether a senior C# reviewer would approve the PR without rewriting half of it.

Claude Code: The Source-Generator Whisperer

Claude Code was the only tool that reliably produced AOT-safe C# on the first try. Ask it to add a JSON endpoint and it reaches for [JsonSerializable] contexts without being asked. Ask it to add a CLI command and it avoids reflection-based System.CommandLine patterns that break under PublishAot=true. The CLAUDE.md file pays for itself here — drop in your TargetFramework, Nullable, ImplicitUsings, and AOT flags and Claude Code never forgets them across a session.

Where Claude Code really pulls ahead is source generators. When we asked it to add a new IOptions<T> pattern with validation, it correctly used [OptionsValidator] from .NET 8+ instead of runtime DataAnnotations. When we asked for OpenAPI docs, it used the new .NET 9 Microsoft.AspNetCore.OpenApi package with source-generated schemas, not Swashbuckle. When we asked for a logger, it used [LoggerMessage] source-generated logging instead of ILogger.LogInformation string interpolation.

Ergonomics: terminal-based, multi-file edits are clean, and the new subagent workflow is brilliant for big refactors. See our Claude Code tutorial and subagents guide for the full setup.

One catch: Claude Code still occasionally hallucinates NuGet package versions. Always run dotnet restore before committing.

Verdict: Best-in-class for anything AOT, source-generator, or minimal-API shaped. Our pick for greenfield .NET 9 work. See the full breakdown in our Windsurf vs Claude Code comparison.

Cursor: The Day-to-Day Champion

Cursor is what most .NET teams will actually use, and it earns it. The IDE-style experience feels native to anyone coming from Rider or Visual Studio, the in-line edits are fast, and the Tab model has clearly been fine-tuned on a mountain of modern C#. It writes records, primary constructors, collection expressions, and required members by default, not as an afterthought.

Where Cursor wins is EF Core and Aspire. Ask it to add a new DbSet<T>, a migration, and the corresponding query, and it produces code that looks like a senior backend dev wrote it — proper AsNoTracking(), compiled queries where they matter, and correct IQueryable composition. Ask it to add a service to the Aspire AppHost and it knows about WithReference, WithEnvironment, and the new WaitFor API.

The killer feature for .NET is .cursorrules — pin your style guide, your nullable preferences, your preferred DI patterns, and Cursor will follow them relentlessly. See our cursorrules guide for battle-tested examples.

Weaknesses: Cursor occasionally misses AOT-safety on first pass and needs a “this must be AOT-compatible” nudge. And it’s still a little too eager to reach for reflection-based solutions when a source generator would be cleaner.

Verdict: Best daily driver for existing .NET codebases, especially anything EF Core or Aspire shaped. See Cursor vs Copilot 2026 for more.

GitHub Copilot: The Visual Studio Native

If you live in Visual Studio 2026, Copilot is the path of least resistance. The integration is deeper than anything else — it reads your .editorconfig, respects your analyzer suite, and the new Copilot Chat agent mode can actually run dotnet build and dotnet test in the integrated terminal and iterate on failures.

Copilot writes perfectly competent C# 13. Records, pattern matching, collection expressions, required members, primary constructors — all present, all idiomatic. It’s particularly strong on XML doc comments and Roslyn analyzer compliance, two things the other tools treat as afterthoughts.

Where it falls behind is the bigger refactors. Ask Copilot to migrate a controller to a minimal API and you’ll get a working result; ask Claude Code or Cursor and you’ll get a working result that also uses source-generated OpenAPI, output caching, and request validation. Copilot is conservative by design, which is a feature in enterprise .NET and a drawback in greenfield work.

Verdict: The safest choice for big enterprise .NET teams on Visual Studio. Pairs well with the other tools for bigger refactors.

Windsurf: The Minimal-API Specialist

Windsurf produced the cleanest minimal-API code of anything we tested. Every endpoint was a typed delegate, every request model was a record, every response was Results.Ok(...), and route groups were used correctly from the first prompt. It also handled the output-caching and rate-limiting middleware from .NET 9 better than anything else.

Cascade’s multi-file awareness really shines on ASP.NET solutions. Ask it to add a new feature and it touches the endpoint, the validator, the handler, the DI registration, and the integration test — all in one coherent diff. The review experience is the best of any tool we tested.

Weaknesses: native AOT support is hit-or-miss, and Windsurf occasionally suggests trim-unsafe patterns that break PublishAot=true. Always run an AOT build before merging.

Verdict: Best choice for minimal-API-heavy services. Pairs brilliantly with Claude Code for AOT work. Full breakdown in Windsurf vs Claude Code.

Aider: The C# Diehard’s Tool

Aider isn’t for everyone, but .NET devs who want to review every diff by hand will love it. Git-native, terminal-based, and ruthlessly focused on producing the smallest correct change. Pair it with Claude Opus 4.5 or GPT-5 and you get production-quality C# with a paper trail.

Weaknesses: no IDE integration, so IntelliSense, code lens, and the Roslyn analyzer suite are out of the loop until you switch back to your editor. And the context window management is manual — you have to /add the files you want in scope.

Verdict: Power-user choice. Not for juniors. Works best as a surgical tool alongside Cursor or Rider.

The Things All Five Tools Still Get Wrong

A few patterns none of these tools nail reliably on .NET 9:

  • Source-generated regex. Every tool still defaults to new Regex(...) instead of [GeneratedRegex]. Add it to your style guide.
  • IAsyncEnumerable<T>. All five still reach for List<T> when streaming would be correct. Worth a prompt-level reminder.
  • ConfigureAwait(false) in libraries. Most tools forget it unless you explicitly ask. Pin it in your rules file.
  • Native AOT trim warnings. Only Claude Code reliably checks for them. Always run dotnet publish -r linux-x64 -c Release before merging AOT code from any tool.

These are fixable with good CLAUDE.md or .cursorrules files — but expect to do the fixing yourself.

Our Recommendation

If you’re starting a new .NET 9 project in 2026: Claude Code for greenfield, Cursor for day-to-day, Copilot inside Visual Studio. That’s the stack we’d run if we were building an enterprise .NET service today.

If you’re in a big existing .NET codebase with a mature Roslyn analyzer suite, .editorconfig, and strict PR review: Copilot as the daily driver, Cursor for bigger refactors, Claude Code for anything touching source generators or AOT. The redundancy pays off on reviews.

For pricing breakdowns, see our AI coding tools pricing guide. For general tool ranking, see best AI coding tools 2026. For other language and framework verticals, see our guides for TypeScript, Python, Go, Rust, Next.js, React, Vue, Svelte, Django, FastAPI, Laravel, Rails, and Spring Boot. And if you want to stop shipping broken AI-generated code, start with how to review AI code and debugging AI-generated code.

The tools are good enough that “AI can’t write .NET” is no longer a real excuse. Pick one, pin your rules file, and ship.

Join the Discussion