Skip to main content

AI in .NET Tutorials: LLMs, Agents, RAG and ML.NET

Last updated: October 6, 2026

Every AI and machine learning article on this site for C# and .NET developers: calling large language models from C#, building agents and RAG chatbots, running models locally, training your own with ML.NET and TorchSharp, and AI tools for writing and reviewing C# code. Posts with a tested mark were rewritten from a working project; the others are tutorials that have not been re-run yet, so check package versions before you copy code.

Start here

Your situationRead this
CS0246: The type or namespace name 'AnalyzeDocumentContent' could not be found after updating Azure.AI.DocumentIntelligenceDocument Intelligence: the GA breaking changes
An invoice total comes back null because the field is number, not currencyDocument Intelligence: amounts gotcha
Choosing between GitHub Copilot, Claude Code, Codex, Cursor and JetBrains AI for C#AI code generation tools compared
You want a chatbot over your own documentsRAG chatbot with Semantic Kernel
You want an LLM without sending data to a cloud APILocal AI with Ollama
You want to train a model on your own data in C#ML.NET: your first model

1. Call an LLM from C#

Start with the first one if you use OpenAI directly, the second if your company is on Azure.

2. Agents, RAG and search

3. Run models locally and process documents

  • Local AI with Ollama: calling Ollama with HttpClient and OllamaSharp, streaming, ASP.NET Core integration and the OpenAI-compatible endpoint.
  • Azure AI Document Intelligence: the SDK 1.0 GA breaking changes, invoice extraction with real output, confidence scores, long-running operations and free-tier limits. (rewritten; SDK run against Microsoft's sample responses, no live Azure calls)

4. Train your own models

ML.NET for classic machine learning inside a .NET app, TorchSharp when you need PyTorch-style deep learning.

  • ML.NET: your first model: data models, pipeline, training, evaluation, saving the model, PredictionEnginePool and AutoML.
  • ML.NET image classification: loading images from disk, training, honest evaluation and serving the model from ASP.NET Core.
  • NLP with ML.NET: sentiment analysis, text featurization, multi-class classification and transformer-based text classification.
  • Recommendation system with ML.NET: collaborative filtering with matrix factorization, top-N recommendations and what the metrics mean.
  • TorchSharp deep learning: tensors, a first network, custom modules, mini-batch training, memory management and loading PyTorch models.

5. AI tools for writing C#

  • Best AI code generation tools for C#: Copilot, Claude Code, Codex, Cursor, JetBrains AI and Kiro compared, with three generated samples run and the bugs found in them. (rewritten; samples run on .NET 10)
  • GitHub Copilot in Visual Studio: setup, inline completions, Copilot Chat for refactoring and tests, and agent mode.
  • GitHub Copilot tips for C#: steering with comments and signatures, custom instructions for a .NET repo, agent mode with tests as guardrails and the usual mistakes.
  • AI code review in C#: a review bot that reads the diff, posts comments and runs in GitHub Actions, plus Roslyn for extra context.

Related guides

Hosting an AI feature behind an API? The ASP.NET Core tutorials guide covers rate limiting, health checks and background jobs. For the cloud services these posts call, see the cloud and security guide.

Comments

Popular posts from this blog

.NET MAUI Tutorial 2026: Build Cross-Platform Apps in C#

Learn .NET MAUI in 2026 to build iOS, Android, Windows & Mac apps from one C# codebase. Start this cross-platform tutorial with code examples today. .NET MAUI (Multi-platform App UI) is Microsoft's framework for building native iOS, Android, Windows, and macOS apps from a single C# codebase . If you've ever wanted to ship a mobile app without learning Swift, Kotlin, and Win32 separately, this .NET MAUI tutorial for 2026 is your starting point. In this guide you'll learn what .NET MAUI is, why it matters for cross-platform app development in C#, and how to build your first working app — with runnable code examples and the best practices senior engineers actually use in production. What Is .NET MAUI and Why Use It in 2026? .NET MAUI is the evolution of Xamarin.Forms, fully integrated into the modern .NET runtime. With one project and one language — C# — you target four platforms. The framework compiles to native UI controls on each device, so a button on iOS...

Angular 14 : 404 error during refresh page after deployment

In this article, We will learn how to solve 404 file or directory not found angular error in production.  Refresh browser angular 404 file or directory not found error You have built an Angular app and created a production build with ng build --prod You deploy it to a production server. Everything works fine until you refresh the page. The app throws The requested URL was not found on this server message (Status code 404 not found). It appears that angular routing not working on the production server when you refresh the page. The error appears on the following scenarios When you type the URL directly in the address bar. When you refresh the page The error appears on all the pages except the root page.   Reason for the requested URL was not found on this server error In a Multi-page web application, every time the application needs to display a page it has to send a request to the web server. You can do that by either typing the URL in the address bar, clicking on the Me...

Angular 14 CRUD Operation with Web API .Net 6.0

How to Perform CRUD Operation Using Angular 14 In this article, we will learn the angular crud (create, read, update, delete) tutorial with ASP.NET Core 6 web API. We will use the SQL Server database and responsive user interface for our Web app, we will use the Bootstrap 5. Let's start step by step. Step 1 - Create Database and Web API First we need to create Employee database in SQL Server and web API to communicate with database. so you can use my previous article CRUD operations in web API using net 6.0 to create web API step by step. As you can see, after creating all the required API and database, our API creation part is completed. Now we have to do the angular part like installing angular CLI, creating angular 14 project, command for building and running angular application...etc. Step 2 - Install Angular CLI Now we have to install angular CLI into our system. If you have already installed angular CLI into your system then skip this step.  To install angular CLI ope...