Skip to content

Migrate VectorStoreRAG and Concepts samples to CommunityToolkit.VectorData packages#14170

Draft
adamsitnik with Copilot wants to merge 9 commits into
mainfrom
copilot/update-package-names
Draft

Migrate VectorStoreRAG and Concepts samples to CommunityToolkit.VectorData packages#14170
adamsitnik with Copilot wants to merge 9 commits into
mainfrom
copilot/update-package-names

Conversation

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

Microsoft.SemanticKernel.Connectors.* vector store packages are moving to CommunityToolkit.VectorData.*. This updates the VectorStoreRAG and Concepts sample projects to reference the new package IDs and namespaces.

Description

Package reference updates (Directory.Packages.props, VectorStoreRAG.csproj, Concepts.csproj):

Old New Version
Microsoft.SemanticKernel.Connectors.AzureAISearch CommunityToolkit.VectorData.AzureAISearch 1.0.0-preview.3
Microsoft.SemanticKernel.Connectors.CosmosMongoDB CommunityToolkit.VectorData.CosmosMongoDB 1.0.0-preview.1
Microsoft.SemanticKernel.Connectors.CosmosNoSql CommunityToolkit.VectorData.CosmosNoSql 1.0.0-preview.1
Microsoft.SemanticKernel.Connectors.InMemory CommunityToolkit.VectorData.InMemory 1.0.0-preview.3
Microsoft.SemanticKernel.Connectors.PgVector CommunityToolkit.VectorData.PgVector 1.0.0-preview.3
Microsoft.SemanticKernel.Connectors.Pinecone CommunityToolkit.VectorData.Pinecone 1.0.0-preview.3
Microsoft.SemanticKernel.Connectors.Qdrant CommunityToolkit.VectorData.Qdrant 1.0.0-preview.3
Microsoft.SemanticKernel.Connectors.Redis CommunityToolkit.VectorData.Redis 1.0.0-preview.3
Microsoft.SemanticKernel.Connectors.Weaviate CommunityToolkit.VectorData.Weaviate 1.0.0-preview.3

Namespace updates (24 .cs files in Concepts/):

// Before
using Microsoft.SemanticKernel.Connectors.InMemory;
// After
using CommunityToolkit.VectorData.InMemory;

DI extension methods (AddInMemoryVectorStore, AddQdrantCollection, etc.) moved to Microsoft.Extensions.DependencyInjection in the CT packages — all affected files already had that using, so no additional changes needed there.

API compatibility fixes:

  • [VectorStoreVector(Dimensions: N)][VectorStoreVector(N)] in two files — the new Microsoft.Extensions.VectorData.Abstractions constructor uses a positional parameter named dimensions (lowercase), so the old named-argument form no longer compiles.
  • SharpCompress pin bumped 0.48.00.48.1 in Directory.Packages.propsCommunityToolkit.VectorData.CosmosMongoDB pulls MongoDB.Driver 3.10.0 which requires >= 0.48.1.
  • Added <AzureCosmosDisableNewtonsoftJsonCheck>true</AzureCosmosDisableNewtonsoftJsonCheck> to both sample csproj files — CommunityToolkit.VectorData.CosmosNoSql pulls Microsoft.Azure.Cosmos 3.61.0 which added a mandatory Newtonsoft.Json explicit-reference check not present in the prior version.

Contribution Checklist

Copilot AI changed the title Migrate SK connector packages to CommunityToolkit.VectorData in samples Migrate VectorStoreRAG and Concepts samples to CommunityToolkit.VectorData packages Jul 20, 2026
Copilot AI requested a review from adamsitnik July 20, 2026 17:28

@adamsitnik adamsitnik left a comment

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.

@copilot please address my feedback

Comment thread dotnet/samples/Concepts/Concepts.csproj
Comment thread dotnet/samples/Concepts/Concepts.csproj Outdated
Comment thread dotnet/samples/Demos/VectorStoreRAG/VectorStoreRAG.csproj Outdated
Comment thread dotnet/Directory.Packages.props Outdated
Copilot AI requested a review from adamsitnik July 21, 2026 12:45
Comment thread dotnet/Directory.Packages.props Outdated

@adamsitnik adamsitnik left a comment

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.

@copilot fix following build failure:

/home/runner/work/semantic-kernel/semantic-kernel/dotnet/samples/GettingStartedWithVectorStores/GettingStartedWithVectorStores.csproj : error NU1010: The following PackageReference items do not define a corresponding PackageVersion item: Microsoft.SemanticKernel.Connectors.AzureAISearch, Microsoft.SemanticKernel.Connectors.InMemory, Microsoft.SemanticKernel.Connectors.Redis. Projects using Central Package Management must declare PackageReference and PackageVersion items with matching names. For more information, visit https://aka.ms/nuget/cpm/gettingstarted [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/SK-dotnet.slnx]
/home/runner/work/semantic-kernel/semantic-kernel/dotnet/samples/GettingStartedWithTextSearch/GettingStartedWithTextSearch.csproj : error NU1010: The following PackageReference items do not define a corresponding PackageVersion item: Microsoft.SemanticKernel.Connectors.InMemory. Projects using Central Package Management must declare PackageReference and PackageVersion items with matching names. For more information, visit https://aka.ms/nuget/cpm/gettingstarted [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/SK-dotnet.slnx]
/home/runner/work/semantic-kernel/semantic-kernel/dotnet/samples/Demos/OnnxSimpleRAG/OnnxSimpleRAG.csproj : error NU1010: The following PackageReference items do not define a corresponding PackageVersion item: Microsoft.SemanticKernel.Connectors.InMemory. Projects using Central Package Management must declare PackageReference and PackageVersion items with matching names. For more information, visit https://aka.ms/nuget/cpm/gettingstarted [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/SK-dotnet.slnx]
/home/runner/work/semantic-kernel/semantic-kernel/dotnet/samples/Demos/ModelContextProtocolClientServer/MCPServer/MCPServer.csproj : error NU1010: The following PackageReference items do not define a corresponding PackageVersion item: Microsoft.SemanticKernel.Connectors.InMemory. Projects using Central Package Management must declare PackageReference and PackageVersion items with matching names. For more information, visit https://aka.ms/nuget/cpm/gettingstarted [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/SK-dotnet.slnx]
/home/runner/work/semantic-kernel/semantic-kernel/dotnet/samples/Demos/AgentFrameworkWithAspire/ChatWithAgent.ApiService/ChatWithAgent.ApiService.csproj : error NU1010: The following PackageReference items do not define a corresponding PackageVersion item: Microsoft.SemanticKernel.Connectors.AzureAISearch. Projects using Central Package Management must declare PackageReference and PackageVersion items with matching names. For more information, visit https://aka.ms/nuget/cpm/gettingstarted [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/SK-dotnet.slnx]
/home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.UnitTests/SemanticKernel.UnitTests.csproj : error NU1010: The following PackageReference items do not define a corresponding PackageVersion item: Microsoft.SemanticKernel.Connectors.InMemory. Projects using Central Package Management must declare PackageReference and PackageVersion items with matching names. For more information, visit https://aka.ms/nuget/cpm/gettingstarted [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/SK-dotnet.slnx]

make sure that none of the projects in this repo keeps using Microsoft.SemanticKernel.Connectors.* packages, just migrate all of them to CommunityToolkit.VectorData.*

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix following build failure:

Fixed in the latest commit. All 6 failing projects have been migrated:

  • GettingStartedWithVectorStores, GettingStartedWithTextSearch, OnnxSimpleRAG, MCPServer, ChatWithAgent.ApiService — PackageReferences updated to CommunityToolkit.VectorData.* and using statements updated in the corresponding .cs files.
  • SemanticKernel.UnitTests — converted from a PackageReference to a ProjectReference to the local src/VectorData/InMemory project (which keeps the Microsoft.SemanticKernel.Connectors.InMemory namespace, so no using changes were needed in the test files).

Copilot AI requested a review from adamsitnik July 21, 2026 13:17
Comment thread dotnet/src/SemanticKernel.UnitTests/SemanticKernel.UnitTests.csproj Outdated

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix following build failures:

Fixed in the latest commit:

  • [VectorStoreVector(Dimensions: N)][VectorStoreVector(N)] in OnnxSimpleRAG/Program.cs and GettingStartedWithVectorStores/Glossary.cs
  • Added CommunityToolkit.VectorData.InMemory PackageReference to IntegrationTests.csproj and updated using Microsoft.SemanticKernel.Connectors.InMemoryusing CommunityToolkit.VectorData.InMemory in ContextualFunctionProviderTests.cs
  • Ran dotnet format on all affected projects to fix the alphabetical ordering of using CommunityToolkit.VectorData.* directives (C sorts before M, so they now appear before using Microsoft.*)

@adamsitnik adamsitnik left a comment

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.

@copilot fix following test failure:

  Failed SemanticKernel.UnitTests.Data.TextSearchServiceCollectionExtensionsTests.AddVectorStoreTextSearchWithNoMappers [8 ms]
[xUnit.net 00:00:02.18]       System.TypeLoadException : GenericArguments[0], 'TRecord', on 'Microsoft.Extensions.VectorData.IVectorSearchable`1[TRecord]' violates the constraint of type parameter 'TRecord'.
[xUnit.net 00:00:02.18]       Stack Trace:
[xUnit.net 00:00:02.18]         /home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.Core/Data/TextSearch/TextSearchServiceCollectionExtensions.cs(38,0): at Microsoft.SemanticKernel.TextSearchServiceCollectionExtensions.<>c__DisplayClass0_0`1.<AddVectorStoreTextSearch>b__0(IServiceProvider sp, Object obj)
[xUnit.net 00:00:02.18]            at Microsoft.Extensions.DependencyInjection.ServiceDescriptor.<>c__DisplayClass5_0.<.ctor>b__0(IServiceProvider sp)
[xUnit.net 00:00:02.18]            at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
[xUnit.net 00:00:02.18]            at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
[xUnit.net 00:00:02.18]            at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)
[xUnit.net 00:00:02.18]            at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
[xUnit.net 00:00:02.18]            at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
[xUnit.net 00:00:02.18]            at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
[xUnit.net 00:00:02.18]            at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope)
[xUnit.net 00:00:02.18]            at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
[xUnit.net 00:00:02.18]            at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
[xUnit.net 00:00:02.18]            at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
[xUnit.net 00:00:02.18]         /home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.UnitTests/Data/TextSearchServiceCollectionExtensionsTests.cs(56,0): at SemanticKernel.UnitTests.Data.TextSearchServiceCollectionExtensionsTests.AddVectorStoreTextSearchWithNoMappers()
[xUnit.net 00:00:02.18]            at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[xUnit.net 00:00:02.18]            at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix following test failure:

Fixed in the latest commit. Root cause: CommunityToolkit.VectorData.InMemory 1.0.0-preview.3 depends on Microsoft.Extensions.VectorData.Abstractions 10.5.2, which added a where TRecord : class constraint to IVectorSearchable<TRecord>. The repo was pinned to 10.1.0 (no constraint), so at runtime the 10.5.2 definition was loaded but the SK Core code (compiled against 10.1.0) didn't enforce the constraint, causing the TypeLoadException.

Changes made:

  • Directory.Packages.props: bumped Microsoft.Extensions.VectorData.Abstractions 10.1.010.5.2 and Microsoft.Extensions.AI.Abstractions 10.5.010.5.2
  • Added where TRecord : class to VectorStoreTextSearch<TRecord>, AddVectorStoreTextSearch<TRecord> (first overload in TextSearchServiceCollectionExtensions), and AddVectorStoreTextSearch<TRecord> in TextSearchKernelBuilderExtensions
  • Generated CompatibilitySuppressions.xml to acknowledge the intentional breaking constraint additions vs the 1.77.0 baseline

All 1609 unit tests pass.

Copilot AI requested a review from adamsitnik July 21, 2026 14:25

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.

@copilot why do we need this file? It seems to be redundant.

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.

The file is required. Here's the chain:

  1. CommunityToolkit.VectorData.InMemory 1.0.0-preview.3 depends on Microsoft.Extensions.VectorData.Abstractions 10.5.2, which added a where TRecord : class constraint to IVectorSearchable<TRecord>.
  2. VectorStoreTextSearch<TRecord> holds a private readonly IVectorSearchable<TRecord>? field and accepts it as constructor parameters — the CLR requires the constraint to be propagated, otherwise it throws TypeLoadException at JIT time (which was the actual unit-test failure you reported earlier).
  3. Adding where TRecord : class to VectorStoreTextSearch<TRecord>, AddVectorStoreTextSearch, and AddVectorStoreTextSearch is a binary-breaking API change relative to the 1.77.0 baseline (which compiled against 10.1.0 where the constraint didn't exist).
  4. Package validation (enabled for Release/Publish builds via <EnablePackageValidation>true</EnablePackageValidation>) therefore raises 9 CP0021 errors — CompatibilitySuppressions.xml suppresses them.

I verified this by removing the file and running dotnet build --configuration Release on SemanticKernel.Core.csproj — it fails with exactly those 9 CP0021 errors. The file is not redundant.

@adamsitnik adamsitnik left a comment

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.

@copilot fix following build failures:

Error: /home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/UnitTests/Search/MockVectorizableTextSearch.cs(7,23): error CS0452: The type 'TRecord' must be a reference type in order to use it as parameter 'TRecord' in the generic type or method 'IVectorSearchable<TRecord>' [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/SemanticKernel.AotTests.csproj::TargetFramework=net10.0]
Error: /home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/UnitTests/Search/MockVectorizableTextSearch.cs(9,68): error CS0452: The type 'TRecord' must be a reference type in order to use it as parameter 'TRecord' in the generic type or method 'VectorSearchResult<TRecord>' [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/SemanticKernel.AotTests.csproj::TargetFramework=net10.0]
Error: /home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/UnitTests/Search/MockVectorizableTextSearch.cs(11,80): error CS0452: The type 'TRecord' must be a reference type in order to use it as parameter 'TRecord' in the generic type or method 'VectorSearchResult<TRecord>' [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/SemanticKernel.AotTests.csproj::TargetFramework=net10.0]
Error: /home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/UnitTests/Search/MockVectorizableTextSearch.cs(16,58): error CS0452: The type 'TRecord' must be a reference type in order to use it as parameter 'TRecord' in the generic type or method 'VectorSearchResult<TRecord>' [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/SemanticKernel.AotTests.csproj::TargetFramework=net10.0]
Error: /home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/UnitTests/Search/MockVectorizableTextSearch.cs(26,58): error CS0452: The type 'TRecord' must be a reference type in order to use it as parameter 'TRecord' in the generic type or method 'VectorSearchResult<TRecord>' [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/SemanticKernel.AotTests.csproj::TargetFramework=net10.0]
Error: /home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/UnitTests/Search/MockVectorizableTextSearch.cs(7,23): error CS0452: The type 'TRecord' must be a reference type in order to use it as parameter 'TRecord' in the generic type or method 'IVectorSearchable<TRecord>' [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/SemanticKernel.AotTests.csproj::TargetFramework=net9.0]
Error: /home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/UnitTests/Search/MockVectorizableTextSearch.cs(9,68): error CS0452: The type 'TRecord' must be a reference type in order to use it as parameter 'TRecord' in the generic type or method 'VectorSearchResult<TRecord>' [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/SemanticKernel.AotTests.csproj::TargetFramework=net9.0]
Error: /home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/UnitTests/Search/MockVectorizableTextSearch.cs(11,80): error CS0452: The type 'TRecord' must be a reference type in order to use it as parameter 'TRecord' in the generic type or method 'VectorSearchResult<TRecord>' [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/SemanticKernel.AotTests.csproj::TargetFramework=net9.0]
Error: /home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/UnitTests/Search/MockVectorizableTextSearch.cs(16,58): error CS0452: The type 'TRecord' must be a reference type in order to use it as parameter 'TRecord' in the generic type or method 'VectorSearchResult<TRecord>' [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/SemanticKernel.AotTests.csproj::TargetFramework=net9.0]
Error: /home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/UnitTests/Search/MockVectorizableTextSearch.cs(26,58): error CS0452: The type 'TRecord' must be a reference type in order to use it as parameter 'TRecord' in the generic type or method 'VectorSearchResult<TRecord>' [/home/runner/work/semantic-kernel/semantic-kernel/dotnet/src/SemanticKernel.AotTests/SemanticKernel.AotTests.csproj::TargetFramework=net9.0]

@copilot make sure you build dotnet/SK-dotnet.slnx succesfully before pushing any changes.

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix following build failures:

Fixed in the latest commit. Added where TRecord : class to MockVectorizableTextSearch<TRecord> to satisfy the constraint now required by IVectorSearchable<TRecord> and VectorSearchResult<TRecord> in Microsoft.Extensions.VectorData.Abstractions 10.5.2. Full SK-dotnet.slnx build passes with 0 errors.

@adamsitnik adamsitnik left a comment

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.

@copilot fix the last build failure:

/app/dotnet/src/InternalUtilities/src/System/PathUtilities.cs(6,1): warning IDE0005: Using directive is unnecessary. [/app/dotnet/src/VectorData/InMemory/InMemory.csproj]
/app/dotnet/src/InternalUtilities/src/System/PathUtilities.cs(6,1): warning IDE0005: Using directive is unnecessary. [/app/dotnet/src/VectorData/Weaviate/Weaviate.csproj]

Copilot AI commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix the last build failure:

Fixed in the latest commit. PathUtilities.cs is only needed by Plugins.Core (FileIOPlugin) — it was being pulled into InMemory.csproj and Weaviate.csproj incidentally via the System/*.cs glob in RestrictedInternalUtilities.props. With Microsoft.Extensions.VectorData.Abstractions 10.5.2, System.Runtime.InteropServices becomes available in those compilation contexts without an explicit using, triggering IDE0005. The fix is to exclude PathUtilities.cs from RestrictedInternalUtilities.props since VectorData connectors never call it. dotnet format --verify-no-changes now passes cleanly for both projects, and the full SK-dotnet.slnx builds with 0 errors.

Copilot AI requested a review from adamsitnik July 21, 2026 15:37
Copilot AI deployed to integration July 21, 2026 15:39 Active
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.

2 participants