Skip to content

Missing type mapping for vector(n) columns in PostgreSQL (pgvector) #3317

@EmilioSanchisCHJ

Description

@EmilioSanchisCHJ

What problem are you trying to solve?

When running the EF Core Power Tools or the standard dotnet ef dbcontext scaffold command against a PostgreSQL database using the pgvector extension, the scaffolding process fails to map the vector data type.

As a result, columns intended for embeddings are skipped, and their associated indexes (such as HNSW) are not generated in the DbContext or entity models.

Steps to Reproduce
1.- Have a PostgreSQL database with the pgvector extension enabled.

2.- Create a table with a vector column, for example:

SQL
CREATE TABLE documento_resumen (
    id SERIAL PRIMARY KEY,
    embedding vector(768)
);
CREATE INDEX idx_doc_resumen_embedding_hnsw ON documento_resumen USING hnsw (embedding vector_cosine_ops);

3.- Run the scaffolding command
4.- Expected Behavior

The scaffolding engine should recognize the vector(n) type (likely mapping it to a Vector or float[] type if the Pgvector.EntityFrameworkCore.PostgreSQL library is present) and include the column and its indexes in the generated code.

5.- Actual Behavior
The following warnings are displayed, and the columns/indexes are omitted:

⚠️ Could not find type mapping for column 'public.documento_resumen.embedding' with data type 'vector(768)'. Skipping column.
⚠️ Unable to scaffold the index 'idx_doc_resumen_embedding_hnsw'. The following columns could not be scaffolded: embedding.
⚠️ Could not find type mapping for column 'public.expediente_resumen.embedding' with data type 'vector(768)'. Skipping column.
⚠️ Unable to scaffold the index 'idx_expediente_resumen_embedding_hnsw'. The following columns could not be scaffolded: embedding.

Describe the solution you'd like

  • Proposed Solution
    Implement support for the vector data type within the scaffolding type mapper. Since pgvector is becoming a standard for AI-driven applications using PostgreSQL, native support for scaffolding these fields would significantly improve the developer experience for RAG (Retrieval-Augmented Generation) workflows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions