EFCore.SqlServer.VectorSearch
9.0.0-preview.1
See the version list below for details.
dotnet add package EFCore.SqlServer.VectorSearch --version 9.0.0-preview.1
NuGet\Install-Package EFCore.SqlServer.VectorSearch -Version 9.0.0-preview.1
<PackageReference Include="EFCore.SqlServer.VectorSearch" Version="9.0.0-preview.1" />
<PackageVersion Include="EFCore.SqlServer.VectorSearch" Version="9.0.0-preview.1" />
<PackageReference Include="EFCore.SqlServer.VectorSearch" />
paket add EFCore.SqlServer.VectorSearch --version 9.0.0-preview.1
#r "nuget: EFCore.SqlServer.VectorSearch, 9.0.0-preview.1"
#:package EFCore.SqlServer.VectorSearch@9.0.0-preview.1
#addin nuget:?package=EFCore.SqlServer.VectorSearch&version=9.0.0-preview.1&prerelease
#tool nuget:?package=EFCore.SqlServer.VectorSearch&version=9.0.0-preview.1&prerelease
EFCore.SqlServer.VectorSearch
This plugin is in prerelease status, and the APIs described below are likely to change before the final release. Vector Functions are in Public Preview. Learn the details about vectors in Azure SQL here: https://aka.ms/azure-sql-vector-public-preview
This Entity Framework Core plugin provides integration between EF and Vector Support in Azure SQL Database, allowing LINQ to be used to perform vector similarity search, and seamless insertion/retrieval of vector data.
To use the plugin, reference the EFCore.SqlServer.VectorSearch nuget package, and enable the plugin by adding UseVectorSearch()
to your UseSqlServer()
config as follows:
builder.Services.AddDbContext<ProductContext>(options =>
options.UseSqlServer("<connection string>", o => o.UseVectorSearch()));
Once the plugin has been enabled, add an ordinary float[]
property to the .NET type being mapped with EF:
public class Product
{
public int Id { get; set; }
public float[] Embedding { get; set; }
}
Finally, configure the property to be mapped as a vector by letting EF Core know using the HasColumnType
method. Use the vector
type and specify the number of dimension that your vector will have:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Product>().Property(p => p.Embedding).HasColumnType("vector(3)");
}
That's it - you can now perform similarity search in LINQ queries! For example, to get the top 5 most similar products:
var someVector = new[] { 1f, 2f, 3f };
var products = await context.Products
.OrderBy(p => EF.Functions.VectorDistance("cosine", p.Embedding, someVector))
.Take(5)
.ToArrayAsync();
A full sample using EF Core and vectors is available here:
https://github.com/Azure-Samples/azure-sql-db-vector-search/tree/main/EF-Core
Ideas? Issues? Let us know on the issues page.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.EntityFrameworkCore.SqlServer (>= 9.0.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on EFCore.SqlServer.VectorSearch:
Package | Downloads |
---|---|
ImmediaC.SimpleCms
ASP.NET Core based CMS |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on EFCore.SqlServer.VectorSearch:
Repository | Stars |
---|---|
marcominerva/SqlDatabaseVectorSearch
A Blazor Web App and Minimal API for performing RAG (Retrieval Augmented Generation) and vector search using the native VECTOR type in Azure SQL Database and Azure OpenAI.
|
|
Azure-Samples/eShopLite
eShopLite is a set of reference .NET applications implementing an eCommerce site with features like Semantic Search, MCP, Reasoning models and more.
|
Version | Downloads | Last Updated |
---|---|---|
9.0.0-preview.2 | 8,976 | 1/16/2025 |
9.0.0-preview.1 | 848 | 1/14/2025 |
8.0.0-preview.1 | 252 | 1/14/2025 |
0.2.0 | 3,012 | 10/30/2024 |
0.1.1 | 680 | 5/30/2024 |
0.1.0 | 158 | 5/24/2024 |