Introduction

SQL Server 2025 is super cool 😎 β€” and naturally, I had to test out the brand-new vector capabilities! If you haven’t checked it out yet, start here:
πŸ”— https://learn.microsoft.com/en-us/sql/sql-server/what-s-new-in-sql-server-2025?view=sql-server-ver17

To explore these features, I leaned into one of my favorite playgrounds: eShopLite β€” a collection of sample scenarios for an eCommerce app with AI-powered Semantic Search. It supports multiple vector database options like Azure AI Search, Qdrant, ChromaDB, and even MCP Servers.

I wanted to create a new scenario using SQL 2025. But I hit a couple of snags:

  1. The .NET Aspire NuGet package for SQL Server defaults to a SQL 2022 image 😬
  2. Even if I spin up a SQL 2025 container β€” how do I enable Vector Search and configure Vector Indexes in the SQL DB Engine?

πŸ‘‰ Here’s how I solved it β€” in just 2 steps.

Step 1 – Create a SQL 2025 Server in .NET Aspire AppHost

Turns out, SQL 2025 is already available in the public image list in 🧊 Docker Hub !
The image I needed: mcr.microsoft.com/mssql/server:2025-latest. But Aspire uses 2022-latest by default…

πŸš€ Solution: Use the right image tag when creating the SQL server resource and that’s it!
( Note: David Fowler guided my in the right direction in this one! )
πŸ‘‰ See usage here.

var builder = DistributedApplication.CreateBuilder(args);

var sql = builder.AddSqlServer("sql")
    .WithLifetime(ContainerLifetime.Persistent)
    .WithImageTag("2025-latest")
    .WithEnvironment("ACCEPT_EULA", "Y");

var productsDb = sql
    .WithDataVolume()
    .AddDatabase("productsDb");

πŸŽ‰ And just like that β€” I had a SQL Server 2025 instance running in a Docker container via Aspire!


Step 2 – Consume the SQL 2025 Server + Use Vector Search

Once my SQL 2025 instance was running, I needed to connect my app and enable vector search.

πŸ’‘ The Aspire helper method .AddSqlServerDbContext<T>() doesn’t support vector search config (yet!)

So I turned to the NuGet package made for this EFCore.SqlServer.VectorSearch.

To make it work, I added this snippet to manually wire up the DB context. πŸ‘‰ Full source here.

var productsDbConnectionString = builder.Configuration.GetConnectionString("productsDb");
builder.Services.AddDbContext<Context>(options =>
    options.UseSqlServer(productsDbConnectionString, o => o.UseVectorSearch()));

Boom πŸ’₯ β€” now my app can access vector indexes, and my Vector Entities can party πŸŽ‰.


🧠 Bonus: Semantic Search Like a Boss

With vector search enabled, I implemented Semantic Search like this. πŸ‘‰ Full source here.

var embeddingSearch = embeddingClient.GenerateEmbedding(search, new() { Dimensions = dimensions });
var vectorSearch = embeddingSearch.Value.ToFloats().ToArray();

var products = await db.Product
    .OrderBy(p => EF.Functions.VectorDistance("cosine", p.Embedding, vectorSearch))
    .Take(3)
    .ToListAsync();

✨ So cool β€” it’s just a few lines of code, and now I’m doing AI-powered search directly inside SQL Server!


Conclusion

πŸš€ SQL Server 2025 + .NET Aspire = Vector-powered awesomeness πŸ’ͺ
I’ve got a vector database running in Docker, wired into my app, and now I’m semantically searching my products like it’s 2035 πŸ€–

If you want to see this in action, I’ve got a πŸ”₯ 5-minute demo video coming soon on my YouTube channel.
πŸ‘‰ Subscribe here: https://youtube.com/elbruno

Stay tuned, stay curious β€” and go build cool stuff with .NET + AI! πŸ’œπŸ§ 

Happy coding!

Greetings

El Bruno

More posts in my blog ElBruno.com.

More info in https://beacons.ai/elbruno


One response to “🧠 Using SQL Server 2025 Vector Search in .NET Aspire – eShopLite Style!”

  1. […] 🧠 Using SQL Server 2025 Vector Search in .NET Aspire – eShopLite Style! (Bruno Capuano) […]

    Like

Leave a reply to Dew Drop – June 24, 2025 (#4445) – Morning Dew by Alvin Ashcraft Cancel reply

Discover more from El Bruno

Subscribe now to keep reading and get access to the full archive.

Continue reading