October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

ASP.NET Core RAG: How to Choose a SQL Server Retrieval Path

A version-aware guide to adding SQL Server vector retrieval and hybrid ranking to an existing ASP.NET Core app, from compatibility checks to chunk storage and evaluation.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You can add retrieval-augmented generation (RAG) to an existing ASP.NET Core app with SQL Server, but the documented EF Core vector workflow has a firm compatibility gate: it requires EF Core 10 or later and SQL Server 2025 or later. Microsoft also identifies Azure SQL Database as a vector-data option in its EF Core 10 release notes. Check the app’s actual EF Core provider and deployment database before designing around vector columns.

Check compatibility before changing your data model

Microsoft says vector support was introduced in EF Core 10.0 and is supported by the SQL Server provider only with SQL Server 2025 and above. EF Core 10 release notes also identify Azure SQL Database for vector data and VECTOR_DISTANCE() support. These requirements apply to the documented vector workflow; do not assume that an app using an older EF Core release or a different SQL database can use the same mapping and queries.

As an Amazon Associate I earn from qualifying purchases.

Inventory the application’s .NET and EF Core versions, configured EF Core provider, database engine and version in each deployment environment, migration process, and existing search behavior. The database that matters is the one the app actually connects to in production, not merely the local development instance. If it does not meet the documented requirements, treat that as a design decision to resolve before adding a vector property.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Microsoft’s SQL Server EF Core vector-search documentation marks VECTOR_SEARCH() and vector indexes as experimental and subject to change. Confirm the current product documentation and release notes before relying on those features in a production rollout.

Represent searchable chunks as durable records

RAG retrieval usually works against passages rather than whole documents. A practical application design is to persist each retrievable chunk as a stable record linked to its source document. Keep the chunk text and useful metadata alongside an embedding. Stable chunk identifiers make it possible to combine results from different retrieval methods and to update or remove passages when the source changes.

This entity shape is an implementation recommendation, not a Microsoft-prescribed schema. Decide what metadata the application needs—for example, source identity or fields used to filter results—based on its corpus and retrieval behavior.

Map the embedding to a dimensioned vector column

Microsoft’s EF Core provider maps a SqlVector<float> property to a SQL vector(n) column. Set n to the number of dimensions produced by the embedding model you choose. Microsoft’s example uses vector(1536); that is a schema example, not a universal model dimension or recommended default. The model’s output and the database column’s dimension must agree.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Generate vectors when content changes

When creating or refreshing chunks, generate and store an embedding for each chunk. At query time, generate an embedding for the user’s question and compare it with stored vectors. Microsoft points to the Microsoft.Extensions.AI IEmbeddingGenerator abstraction and demonstrates GenerateVectorAsync; the application remains responsible for selecting a provider and model.

Plan refresh behavior as part of the data lifecycle: when source text or chunk boundaries change, the stored text and its embedding need to remain in sync. The cited Microsoft guidance does not prescribe a chunk size, overlap, embedding model, or refresh policy. Choose those for the corpus and test them rather than presenting arbitrary values as platform recommendations.

Choose exact or approximate vector retrieval

For a straightforward baseline, use EF.Functions.VectorDistance() to calculate distance between a query vector and stored vectors, then order by distance. Microsoft notes that exact searches scan rows and can become slow at scale, so measure latency and relevance on the application’s workload as the corpus grows.

Approximate nearest-neighbor retrieval is a different trade-off: it can improve retrieval performance but may return approximate rather than exact neighbors. The documented SQL Server path uses a vector index and VectorSearch(); to request approximate search, create the index and call WithApproximate() after Take(). Microsoft lists cosine, Euclidean, and dot metrics for vector indexes. Cosine is commonly used for text embeddings, but the right metric depends on the selected model and workload.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Start with exact search where it suits the corpus and gives a useful baseline. Consider approximate indexed search only after testing whether its performance and retrieval behavior fit the app. Because Microsoft labels vector indexes and VECTOR_SEARCH() experimental and subject to change, account for that maturity risk in deployment planning.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Combine keyword and semantic candidates with hybrid ranking

Vector retrieval can find passages that express an idea in different words; lexical search can be stronger for exact terms such as names, identifiers, or distinctive phrases. A hybrid retriever combines both candidate sets instead of asking one method to cover both jobs.

  1. Retrieve lexical candidates. Use SQL Server full-text search; Microsoft’s example uses FreeTextTable().
  2. Retrieve semantic candidates. Generate the query embedding and use VectorSearch() for vector retrieval.
  3. Bound both result sets. Request a candidate count appropriate to the application, then combine the results by stable chunk ID so the same chunk returned by both methods is treated as one candidate.
  4. Fuse the rankings. Apply Reciprocal Rank Fusion (RRF) to the lexical and vector result ranks, then return the desired top chunks to the next stage of the RAG pipeline.

Microsoft demonstrates a single EF query pattern combining FreeTextTable() and VectorSearch() with RRF. Candidate counts and ranking behavior still need to be validated against the app’s corpus; the documentation does not establish universal settings.

Validate retrieval against the app’s own questions

Assess retrieval quality and operational behavior before tuning for production. Use representative questions that exercise both exact-term matching and semantic paraphrases, and inspect whether the returned chunks contain the evidence needed to answer them. Measure latency as well as relevance when comparing exact and approximate vector search.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Include names, product or document identifiers, and other exact strings that matter to users.
  • Include paraphrased questions whose wording differs from the source passages.
  • Check whether chunk boundaries preserve the context needed to interpret each result.
  • Compare lexical-only, vector-only, and hybrid results to see which misses each approach corrects.
  • Tune chunking, candidate counts, ranking, and filters against the application’s actual documents and queries.

There is no universal chunk size, overlap, candidate count, or ranking configuration established by the cited platform documentation. The useful settings depend on the corpus, embedding model, search requirements, and deployment constraints.

Sources

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.