Skip to content

Introduce CommunityToolkit.VectorData.SqlServer#16

Merged
adamsitnik merged 9 commits into
CommunityToolkit:mainfrom
adamsitnik:copilot/copy-code-from-dacfx-786
Jul 2, 2026
Merged

Introduce CommunityToolkit.VectorData.SqlServer#16
adamsitnik merged 9 commits into
CommunityToolkit:mainfrom
adamsitnik:copilot/copy-code-from-dacfx-786

Conversation

@adamsitnik

@adamsitnik adamsitnik commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Ports the Microsoft.SqlServer.VectorData provider and conformance tests from microsoft/DacFx#786 into this repository's MEVD structure.

@adamsitnik adamsitnik changed the title Copilot/copy code from dacfx 786 Introduce CommunityToolkit.VectorData.SqlServer Jul 1, 2026
@adamsitnik
adamsitnik requested a review from Copilot July 1, 2026 16:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Introduces a new SQL Server / Azure SQL provider (CommunityToolkit.VectorData.SqlServer) and integrates it into the MEVD solution structure, alongside a new SQL Server conformance test suite to validate provider behavior.

Changes:

  • Added CommunityToolkit.VectorData.SqlServer provider implementation (collections, command builder, model builder, filter translation, DI extensions).
  • Added SQL Server conformance tests (including container-backed test store + Azure SQL-specific cases).
  • Wired new projects and dependencies into the MEVD solution filter and central package versions.

Reviewed changes

Copilot reviewed 43 out of 43 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
MEVD/test/SqlServer.ConformanceTests/TypeTests/SqlServerKeyTypeTests.cs SQL Server-specific key type conformance coverage.
MEVD/test/SqlServer.ConformanceTests/TypeTests/SqlServerEmbeddingTypeTests.cs SQL Server-specific embedding type conformance coverage.
MEVD/test/SqlServer.ConformanceTests/TypeTests/SqlServerDataTypeTests.cs SQL Server-specific data type conformance overrides.
MEVD/test/SqlServer.ConformanceTests/testsettings.json Local test configuration for external SQL Server connection strings.
MEVD/test/SqlServer.ConformanceTests/Support/SqlServerTestStore.cs Test store abstraction using Testcontainers or external SQL Server.
MEVD/test/SqlServer.ConformanceTests/Support/SqlServerTestEnvironment.cs Configuration discovery for SQL Server test environment.
MEVD/test/SqlServer.ConformanceTests/Support/AzureSqlRequiredAttribute.cs Helper for gating Azure SQL / Fabric-only tests.
MEVD/test/SqlServer.ConformanceTests/SqlServerTestSuiteImplementationTests.cs Registers ignored base tests for SQL Server test suite.
MEVD/test/SqlServer.ConformanceTests/SqlServerIndexKindTests.cs SQL Server/Azure SQL index-kind test overrides (e.g., DiskANN).
MEVD/test/SqlServer.ConformanceTests/SqlServerHybridSearchTests.cs SQL Server hybrid search test fixture wiring.
MEVD/test/SqlServer.ConformanceTests/SqlServerFilterTests.cs SQL Server filter semantics overrides for null/negation behavior.
MEVD/test/SqlServer.ConformanceTests/SqlServerEmbeddingGenerationTests.cs Embedding generation + DI registration scenarios for SQL Server.
MEVD/test/SqlServer.ConformanceTests/SqlServerDistanceFunctionTests.cs SQL Server distance-function support/exception expectations.
MEVD/test/SqlServer.ConformanceTests/SqlServerDependencyInjectionTests.cs SQL Server DI registration conformance tests.
MEVD/test/SqlServer.ConformanceTests/SqlServerCommandBuilderTests.cs Unit tests for SQL Server command generation/escaping behavior.
MEVD/test/SqlServer.ConformanceTests/SqlServerCollectionManagementTests.cs Collection lifecycle tests wired to SQL Server test store.
MEVD/test/SqlServer.ConformanceTests/SqlServer.ConformanceTests.csproj New conformance test project definition and dependencies.
MEVD/test/SqlServer.ConformanceTests/README.md Docs for running SQL Server conformance tests locally/externally.
MEVD/test/SqlServer.ConformanceTests/Properties/AssemblyAttributes.cs Assembly-level attributes placeholder (license header).
MEVD/test/SqlServer.ConformanceTests/ModelTests/SqlServerNoVectorModelTests.cs Model tests for collections without vectors.
MEVD/test/SqlServer.ConformanceTests/ModelTests/SqlServerNoDataModelTests.cs Model tests for collections without data properties.
MEVD/test/SqlServer.ConformanceTests/ModelTests/SqlServerMultiVectorModelTests.cs Model tests for collections with multiple vectors.
MEVD/test/SqlServer.ConformanceTests/ModelTests/SqlServerDynamicModelTests.cs Model tests for dynamic/dictionary mapping scenarios.
MEVD/test/SqlServer.ConformanceTests/ModelTests/SqlServerBasicModelTests.cs Additional SQL Server-specific behavioral model tests.
MEVD/src/SqlServer/SqlServerVectorStoreOptions.cs Options type for configuring the SQL Server vector store.
MEVD/src/SqlServer/SqlServerVectorStore.cs Vector store implementation for SQL Server/Azure SQL.
MEVD/src/SqlServer/SqlServerServiceCollectionExtensions.cs DI registration extensions for store and collections (keyed + unkeyed).
MEVD/src/SqlServer/SqlServerModelBuilder.cs Model validation/mapping rules for SQL Server-backed collections.
MEVD/src/SqlServer/SqlServerMapper.cs Materialization/mapping from SqlDataReader into record models.
MEVD/src/SqlServer/SqlServerJsonSerializerContext.cs Source-gen JSON context for JSON-mapped property types.
MEVD/src/SqlServer/SqlServerFilterTranslator.cs SQL Server-specific filter SQL translation.
MEVD/src/SqlServer/SqlServerDynamicCollection.cs Dynamic collection specialization for dictionary-backed records.
MEVD/src/SqlServer/SqlServerConstants.cs SQL Server provider constants (limits, names).
MEVD/src/SqlServer/SqlServerCommandBuilder.cs SQL command generation (DDL/DML/search/hybrid search).
MEVD/src/SqlServer/SqlServerCollectionOptions.cs Options type for SQL Server collections (schema, base options).
MEVD/src/SqlServer/SqlServerCollection.cs Collection implementation (CRUD, vector search, hybrid search).
MEVD/src/SqlServer/SqlServer.csproj New provider project definition and packaging metadata.
MEVD/src/SqlServer/SqlFilterTranslator.cs Provider-agnostic filter translation base used by SQL Server translator.
MEVD/src/SqlServer/README.md Provider usage documentation and basic sample.
MEVD/src/SqlServer/AssemblyInfo.cs Assembly-level attributes placeholder (license header).
MEVD/MEVD.slnf Adds SQL Server provider + conformance tests to solution filter.
Directory.Packages.props Adds central versions for SqlClient + Testcontainers.MsSql.
CommunityToolkit.AI.slnx Adds SQL Server provider + conformance tests to solution listing.

Comment thread MEVD/src/SqlServer/SqlServerCommandBuilder.cs
Comment thread MEVD/src/SqlServer/SqlServerCommandBuilder.cs
Comment thread MEVD/src/SqlServer/SqlServerCommandBuilder.cs
Comment thread MEVD/src/SqlServer/SqlServerFilterTranslator.cs
Comment thread MEVD/test/SqlServer.ConformanceTests/README.md Outdated
@adamsitnik
adamsitnik force-pushed the copilot/copy-code-from-dacfx-786 branch from be604ad to b7b1c5c Compare July 2, 2026 07:38

@adamsitnik adamsitnik left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

LGTM, the PR is ready for review.

If you are curious why this PR introduces fewer lines of code than microsoft/DacFx#786

Image

private const int SqlServerMaxParameters = 2_100;

[Fact]
public async Task Split_batches_to_account_for_max_parameter_limit()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

to other code reviewers: this is one of the very few changes I've made: making this test public, as it was private in the SK repo:

https://github.com/microsoft/semantic-kernel/blob/f25753be0a126138d2eea39b0ca2985252dde25a/dotnet/test/VectorData/SqlServer.ConformanceTests/ModelTests/SqlServerBasicModelTests.cs#L18

@@ -0,0 +1,2 @@
// Licensed to the .NET Foundation under one or more agreements.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

to other code reviewers: microsoft/DacFx#786 was our source of truth, what we needed was to change the license header from // Copyright (c) Microsoft. All rights reserved.


```csharp
using Microsoft.Extensions.VectorData;
using CommunityToolkit.VectorData.SqlServer;

@adamsitnik adamsitnik Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Another change when compared to microsoft/DacFx#786, the namespace is CommunityToolkit.VectorData.SqlServer rather than Microsoft.SqlServer.VectorData


<ItemGroup>
<!-- The HybridSearch tests require running against Azure SQL -->
<Compile Remove="SqlServerHybridSearchTests.cs" />

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To other code reviewers: This is a workaround for dotnet/extensions#7605

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm... It's probably better to not remove the tests entirely, so that they can still run when working locally... If possible, I'd suggest a runtime probe to see whether you're running against Azure, and skipping only if not.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't this what you did for the index tests below? #16 (comment)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

If possible, I'd suggest a runtime probe to see whether you're running against Azure, and skipping only if not

For these particular class, all methods are non-virtual, so I was not able to find a way to customize them.

I've logged #20 to track this

@adamsitnik
adamsitnik requested review from roji and westey-m July 2, 2026 08:08
public virtual async Task DiskAnn()
{
// This test should be conditional (https://github.com/dotnet/extensions/issues/7605)
if (!await AzureSqlHelper.GetIsAzureSqlAsync())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To other code reviewers: This is a workaround for dotnet/extensions#7605

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Also agree that moving to xunit 3 makes sense. In the SK repo we were using some xunit extensions to allow skipping. See:
https://github.com/microsoft/semantic-kernel/blob/main/dotnet/test/VectorData/AzureAISearch.ConformanceTests/Support/AzureAISearchUrlRequiredAttribute.cs
https://github.com/microsoft/semantic-kernel/blob/main/dotnet/test/VectorData/AzureAISearch.ConformanceTests/Properties/AssemblyAttributes.cs

This was very complex though, and while handy, now that xunit 3 supports all this out of the box, unnecessary.

@roji roji left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM on a (very) superficial review, approving as this is a simple code move. See (very) minor comments.

public string? Content { get; set; }

[VectorStoreVector(Dimensions: 1536)]
public ReadOnlyMemory<float> ContentEmbedding { get; set; }

@westey-m westey-m Jul 2, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We may want to modernize these examples to use auto embedding generation. See https://learn.microsoft.com/en-us/dotnet/ai/vector-stores/define-your-data-model?tabs=attributes%2Ckey-attribute%2Cdata-attribute%2Cvector-attribute#automatic-embedding-generation-recommended
E.g:

    [VectorStoreVector(Dimensions: 1536)]
    public string ContentEmbedding => Content;

This also requires configuring the vector store with an Embedding Generator, so if too complex for a simple inline example like this, feel free to ignore. And certainly feel free to do this in a follow up PR if you agree with the suggestion.

@adamsitnik
adamsitnik merged commit e966e4f into CommunityToolkit:main Jul 2, 2026
34 checks passed
@adamsitnik
adamsitnik deleted the copilot/copy-code-from-dacfx-786 branch July 2, 2026 12:30
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.

6 participants