Switch to SqlVector<float> for embeddings

Updated the application to use SQL Server's native vector data type (`SqlVector<float>`) for embeddings, replacing the previous `float[]` or `string` representations.

- Updated `.editorconfig` with new code style preferences and diagnostic rule severities.
- Modified `DocumentChunk.cs` to use `SqlVector<float>` for the `Embedding` property.
- Updated migrations and `ApplicationDbContextModelSnapshot` to reflect the new `SqlVector<float>` type.
- Replaced `AddAzureSql` with `AddSqlServer` in `Program.cs` and removed `UseVectorSearch`.
- Adjusted `DocumentService` and `VectorSearchService` to handle `SqlVector<float>` and updated vector search logic.
- Removed the `EFCore.SqlServer.VectorSearch` package and upgraded EF Core to `10.0.0-rc.1`.
- Made minor adjustments to OpenAPI configuration and dependency management.
This commit is contained in:
Marco Minerva
2025-09-10 16:45:16 +02:00
parent f5011bc44b
commit 404cd7565a
9 changed files with 26 additions and 22 deletions
@@ -1,5 +1,6 @@
// <auto-generated />
using System;
using Microsoft.Data.SqlTypes;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
@@ -17,7 +18,7 @@ namespace SqlDatabaseVectorSearch.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.5")
.HasAnnotation("ProductVersion", "10.0.0-rc.1.25451.107")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@@ -54,8 +55,7 @@ namespace SqlDatabaseVectorSearch.Migrations
b.Property<Guid>("DocumentId")
.HasColumnType("uniqueidentifier");
b.PrimitiveCollection<string>("Embedding")
.IsRequired()
b.Property<SqlVector<float>>("Embedding")
.HasColumnType("vector(1536)");
b.Property<int>("Index")