Description
A project scaffolded with dotnet new aichatweb --provider azureopenai (template Microsoft.Extensions.AI.Templates 10.9.0-preview.3.26411.16, default --vector-store local, which now maps to CommunityToolkit.VectorData.SqliteVec) throws on the first chat/search request:
System.InvalidOperationException: The collection's generic key type is 'String', but the key property 'Key' has type 'Guid'. The generic key type must match the key property type.
The generated code is internally inconsistent about the vector-store key type:
| Generated file |
Key type used |
Services/IngestedChunk.cs |
public required Guid Key { get; set; } |
Program.cs |
builder.Services.AddSqliteCollection<string, IngestedChunk>(...) |
Services/SemanticSearch.cs |
VectorStoreCollection<string, IngestedChunk> |
Services/Ingestion/DataIngestor.cs |
new VectorStoreWriter<string>(...), new IngestionPipeline<string>(...) |
The record's [VectorStoreKey] property is Guid; everything that binds the collection uses string as TKey. SqliteVec validates that these match (SqliteModelBuilder.ValidateKeyProperty) and throws when building the model.
Reproduction Steps
Reproduce via the template
dotnet new install Microsoft.Extensions.AI.Templates::10.9.0-preview.3.26411.16
dotnet new aichatweb --provider azureopenai -o ReproGuid
- Set
AzureOpenAI:Endpoint + chat/embedding deployment names, then dotnet run
- Send any chat message. The exception is thrown from
SemanticSearch the first
time the collection is resolved. (dotnet build succeeds — this is runtime only.)
Unhandled exception. System.InvalidOperationException: The collection's generic key type is 'String', but the key property 'Key' has type 'Guid'. The generic key type must match the key property type.
at Microsoft.Extensions.VectorData.ProviderServices.CollectionModelBuilder.ValidateKeyProperty(KeyPropertyModel keyProperty)
at CommunityToolkit.VectorData.SqliteVec.SqliteModelBuilder.ValidateKeyProperty(KeyPropertyModel keyProperty) in /home/runner/work/AI/AI/MEVD/src/SqliteVec/SqliteModelBuilder.cs:line 25
at Microsoft.Extensions.VectorData.ProviderServices.CollectionModelBuilder.ValidateProperty(PropertyModel propertyModel, VectorStoreCollectionDefinition definition)
at Microsoft.Extensions.VectorData.ProviderServices.CollectionModelBuilder.Validate(Type type, VectorStoreCollectionDefinition definition)
at Microsoft.Extensions.VectorData.ProviderServices.CollectionModelBuilder.Build(Type recordType, Type keyType, VectorStoreCollectionDefinition definition, IEmbeddingGenerator defaultEmbeddingGenerator)
at CommunityToolkit.VectorData.SqliteVec.SqliteCollection`2..ctor(...)
at CommunityToolkit.VectorData.SqliteVec.SqliteVectorStore.GetCollection[TKey,TRecord](String name, VectorStoreCollectionDefinition definition) in /home/runner/work/AI/AI/MEVD/src/SqliteVec/SqliteVectorStore.cs:line 69
at Program.<Main>$(String[] args)
Expected behavior
The scaffolded project builds and runs; document ingestion and semantic search work out of the box.
Actual behavior
InvalidOperationException the first time the IngestedChunk collection is built, because the [VectorStoreKey] property is Guid while the collection is bound with string as TKey.
Regression?
Appears to be fallout from the DataIngestion key-type migration from string to auto-generated Guid keys (#7410, #7396, #7557). Services/IngestedChunk.cs was updated to Guid Key, but Program.cs / SemanticSearch.cs / DataIngestor.cs and the pinned Microsoft.Extensions.DataIngestion version were not.
Known Workarounds
Make the key type consistent. The only variant that compiles against the pinned
package set is string — change IngestedChunk.Key back to string:
[VectorStoreKey(StorageName = "key")]
[JsonPropertyName("key")]
public required string Key { get; set; }
Going the other way (AddSqliteCollection<Guid, IngestedChunk>, VectorStoreCollection<Guid, IngestedChunk>, VectorStoreWriter<Guid>, IngestionPipeline<Guid>) does not compile with Microsoft.Extensions.DataIngestion 10.9.0-preview.1.26411.16, because SemanticSimilarityChunker is IngestionChunker<string> there:
error CS1503: Argument 2: cannot convert from
'Microsoft.Extensions.DataIngestion.Chunkers.SemanticSimilarityChunker' to
'Microsoft.Extensions.DataIngestion.IngestionChunker<System.Guid>'
Configuration
- Template:
Microsoft.Extensions.AI.Templates 10.9.0-preview.3.26411.16
- .NET SDK:
10.0.400
--provider azureopenai, --vector-store local (SqliteVec), no Aspire
- Generated package references:
Microsoft.Extensions.AI / Microsoft.Extensions.AI.OpenAI 10.9.0
Microsoft.Extensions.DataIngestion / .Markdig 10.9.0-preview.1.26411.16
CommunityToolkit.VectorData.SqliteVec 1.0.1-preview
Microsoft.Extensions.VectorData.Abstractions 10.7.0 (transitive)
- OS: macOS 12.7.6 (x64). Isolated repro is OS-independent.
Other information
dotnet build on the generated project succeeds; the failure is purely at runtime when the SqliteVec model is built (eagerly in GetCollection, or lazily via SemanticSearch in the template).
Description
A project scaffolded with
dotnet new aichatweb --provider azureopenai(templateMicrosoft.Extensions.AI.Templates10.9.0-preview.3.26411.16, default--vector-store local, which now maps toCommunityToolkit.VectorData.SqliteVec) throws on the first chat/search request:The generated code is internally inconsistent about the vector-store key type:
Services/IngestedChunk.cspublic required Guid Key { get; set; }Program.csbuilder.Services.AddSqliteCollection<string, IngestedChunk>(...)Services/SemanticSearch.csVectorStoreCollection<string, IngestedChunk>Services/Ingestion/DataIngestor.csnew VectorStoreWriter<string>(...),new IngestionPipeline<string>(...)The record's
[VectorStoreKey]property isGuid; everything that binds the collection usesstringasTKey. SqliteVec validates that these match (SqliteModelBuilder.ValidateKeyProperty) and throws when building the model.Reproduction Steps
Reproduce via the template
dotnet new install Microsoft.Extensions.AI.Templates::10.9.0-preview.3.26411.16dotnet new aichatweb --provider azureopenai -o ReproGuidAzureOpenAI:Endpoint+ chat/embedding deployment names, thendotnet runSemanticSearchthe firsttime the collection is resolved. (
dotnet buildsucceeds — this is runtime only.)Expected behavior
The scaffolded project builds and runs; document ingestion and semantic search work out of the box.
Actual behavior
InvalidOperationExceptionthe first time theIngestedChunkcollection is built, because the[VectorStoreKey]property isGuidwhile the collection is bound withstringasTKey.Regression?
Appears to be fallout from the DataIngestion key-type migration from
stringto auto-generatedGuidkeys (#7410, #7396, #7557).Services/IngestedChunk.cswas updated toGuid Key, butProgram.cs/SemanticSearch.cs/DataIngestor.csand the pinnedMicrosoft.Extensions.DataIngestionversion were not.Known Workarounds
Make the key type consistent. The only variant that compiles against the pinned
package set is
string— changeIngestedChunk.Keyback tostring:Going the other way (
AddSqliteCollection<Guid, IngestedChunk>,VectorStoreCollection<Guid, IngestedChunk>,VectorStoreWriter<Guid>,IngestionPipeline<Guid>) does not compile withMicrosoft.Extensions.DataIngestion10.9.0-preview.1.26411.16, becauseSemanticSimilarityChunkerisIngestionChunker<string>there:Configuration
Microsoft.Extensions.AI.Templates10.9.0-preview.3.26411.1610.0.400--provider azureopenai,--vector-store local(SqliteVec), no AspireMicrosoft.Extensions.AI/Microsoft.Extensions.AI.OpenAI10.9.0Microsoft.Extensions.DataIngestion/.Markdig10.9.0-preview.1.26411.16CommunityToolkit.VectorData.SqliteVec1.0.1-previewMicrosoft.Extensions.VectorData.Abstractions10.7.0(transitive)Other information
dotnet buildon the generated project succeeds; the failure is purely at runtime when the SqliteVec model is built (eagerly inGetCollection, or lazily viaSemanticSearchin the template).