0

I'm trying to create a index, like this one:

CREATE INDEX example1_gpx ON example1 USING GIST (geography(geomcol));

Using EF codefirst, I did this on codefirst:

    builder.HasIndex(x => new
        {
            x.GeoLocation
        })
        .HasMethod("GIST");

but I can't specify that it's a column of type geography.

How I can create this index using CodeFirst ?

1 Answer 1

3

Your index above seems to apply a geography() conversion to a geometry column; if so, it's an expression index (as opposed to a simple index over a column). The Npgsql EF Core provider doesn't currently support modeling expression indexes (see this issue), but you can always use raw SQL to create the index in migrations.

However, I'd recommend thinking why you're converting a geometry column into geography in an expression index; you may want to consider making your column geography instead. Another option is to have an additional generated column of type geography alongside the geometry column.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.