Reputation: 149
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 ?
Upvotes: 0
Views: 1070
Reputation: 16722
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.
Upvotes: 3