Skip to content

.Net: [MEVD] Allow mapping the same .NET property to both data and vector properties in the database #11734

Closed

Description

@roji

In #10492, we're adding the ability to map arbitrary properties to a data store vector property, via an IEmbeddingGenerator:

[VectorStoreRecordVector(Dimensions: 3)]
public string Description { get; set; }

The slight issue here is that currently maps Description only to a vector property; we believe there are non-contrived scenarios out there where users want to fetch back the description (as a string) when searching/getting records. We also believe some users would reasonably expect the above to just roundtrip, and would be a bit surprised when it doesn't.

Option 1 (Current): two .NET properties, one pointing to the other

The current way for users to do this is to have two properties as follows:

[VectorStoreRecordData]
public string Description { get; set; }

[VectorStoreRecordVector(Dimensions: 3)]
public string DescriptionEmbedding => Description;

Note that this also allows easily e.g. concatenating multiple string properties together for embedding generation, or any arbitrary transformation.

Option 2: single .NET property, implicitly mapped to both vector and data

One possible design would be to implicitly map the above single .NET property to two database properties for the user. That is, the single Description .NET property would be mapped to a Description data property, and also to e.g. a Description_Embedding property (via some arbitrary naming convention). We don't like this design because:

  • There's an excess of "magic" (e.g. the naming convention)
  • The data property can't be configured (to e.g. be indexed)
  • Generally because the two-property mapping is non-obvious.

If we did want to do this, we'd need to do it now, since doing it later would be a breaking change.

Option 3: single .NET property, multiple attributes

An alternative would be for the user to simply annotated the same .NET property with two attributes:

[VectorStoreRecordVector(Dimensions: 3, StorageName = "Description_Embedding")]
[VectorStoreRecordData]
public string Description { get; set; }
  • This makes it much more explicit that the same .NET property is mapped to two database properties.
  • It allows configuring each one separately, via the separate attribute (or record definition)
  • This only works in the case where a single string property that's already mapped to a single data property in the databae needs to be embedding-generated. Other scenarios, e.g. concatenating multiple properties still need to be addressed via option 1 above.

Importantly, this is something that we should be able to implement later without any breaking changes. We currently throw in model validation when the same .NET property has more than one attribute - we'd just relax that.

/cc Adam Sitnik (@adamsitnik) Eduard van Valkenburg (@eavanvalkenburg) hopefully this captures our conversation!
/cc westey (@westey-m) Dmytro Struk (@dmytrostruk)

Activity

  1. changed the title [-][MEVD] Allow mapping the same .NET property to both data and vector properties in the database[/-] [+].Net: [MEVD] Allow mapping the same .NET property to both data and vector properties in the database[/+] on Apr 25, 2025
  2. github-actions commented on Jul 25, 2025

    @github-actions
    Contributor

    This issue is stale because it has been open for 90 days with no activity.

  3. added
    staleIssue is stale because it has been open for a while and has no activity
    on Jul 25, 2025
  4. github-actions commented on May 20, 2026

    @github-actions
    Contributor

    This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETIssue or Pull requests regarding .NET codemsft.ext.vectordataRelated to Microsoft.Extensions.VectorDatastaleIssue is stale because it has been open for a while and has no activity

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions