Skip to content

Implement latest SQL Server approximate vector search feature#38075

Merged
roji merged 2 commits intomainfrom
roji/vector-search-updates
Apr 10, 2026
Merged

Implement latest SQL Server approximate vector search feature#38075
roji merged 2 commits intomainfrom
roji/vector-search-updates

Conversation

@roji roji requested a review from a team as a code owner April 10, 2026 09:14
Copilot AI review requested due to automatic review settings April 10, 2026 09:14
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates EF Core’s SQL Server vector search support to match the latest VECTOR_SEARCH() syntax/requirements (Azure SQL-only at the moment), shifting result limiting to LINQ composition and emitting the WITH APPROXIMATE modifier.

Changes:

  • Removed the topN argument from SqlServerQueryableExtensions.VectorSearch() and updated translation/SQL generation accordingly.
  • Updated SQL generation to append WITH APPROXIMATE when TOP(...) is used over a VECTOR_SEARCH() source.
  • Updated functional tests to run only on Azure SQL, seed enough rows for vector index creation, and assert the new SQL shape.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/EFCore.SqlServer.FunctionalTests/Query/Translations/VectorTranslationsSqlServerTest.cs Adjusts vector-search tests for Azure-only execution, new query shape (OrderBy/Take), and updated seeding/index creation.
test/EFCore.SqlServer.FunctionalTests/EFCore.SqlServer.FunctionalTests.csproj Adds Azure SqlClient extensions package to support Azure SQL connectivity scenarios in tests.
src/EFCore.SqlServer/Query/Internal/SqlServerQuerySqlGenerator.cs Updates VECTOR_SEARCH() TVF SQL and adds WITH APPROXIMATE emission for TOP(...).
src/EFCore.SqlServer/Query/Internal/SqlServerQueryableMethodTranslatingExpressionVisitor.cs Updates translation for VectorSearch to drop the topN argument.
src/EFCore.SqlServer/Extensions/VectorSearchResult.cs Updates XML doc reference to the new VectorSearch signature.
src/EFCore.SqlServer/Extensions/SqlServerQueryableExtensions.cs Removes topN from the public API and updates the expression construction.
Directory.Packages.props Adds centrally-managed version for Microsoft.Data.SqlClient.Extensions.Azure.
.gitignore Ignores language server cache files (*.lscache).

@roji roji force-pushed the roji/vector-search-updates branch from 6755e3f to 7244a28 Compare April 10, 2026 09:33
Copilot AI review requested due to automatic review settings April 10, 2026 09:41
@roji roji force-pushed the roji/vector-search-updates branch from 7244a28 to 0e2e40a Compare April 10, 2026 09:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

@roji roji force-pushed the roji/vector-search-updates branch from 0e2e40a to d970878 Compare April 10, 2026 09:49
Copilot AI review requested due to automatic review settings April 10, 2026 18:55
@roji roji force-pushed the roji/vector-search-updates branch from d970878 to 65b1032 Compare April 10, 2026 18:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated no new comments.

.gitignore Outdated
Comment on lines +345 to +347

# Language Server cache
*.lscache
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can revert

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to though? These starting appearing for me, seems right to ignore them no?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you didn't say that it was already done.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trust me 😆

<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.58.0" />
<!-- SQL Server dependencies -->
<PackageVersion Include="Microsoft.Data.SqlClient" Version="7.0.0" />
<PackageVersion Include="Microsoft.Data.SqlClient.Extensions.Azure" Version="1.0.0" />
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should only use this in tests

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are... But the version is managed centrally here. Any issue?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add it here to make sure that it's not used in shipped code: https://github.com/dotnet/efcore/blob/main/test/Directory.Packages.props

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, seems overly defensive given one has to actually add a <PackageReference> (these are just version nodes). But will do.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The primary reason for this file is to allow to use different versions (higher) in tests, but I think the above is a nice side-effect.

@roji roji enabled auto-merge (squash) April 10, 2026 22:06
@roji roji merged commit 002d1ca into main Apr 10, 2026
15 checks passed
@roji roji deleted the roji/vector-search-updates branch April 10, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants