Efcore.pg: Support for specifying column SRID

Created on 21 Nov 2018  路  7Comments  路  Source: npgsql/efcore.pg

Hi,

is It possible to specify the column SRID at model creation? (v2.2.0-preview1)

I'm using the code first approach and the POSTGIS columns created (automatically) have SRID set to 0.
I think this could be done using Migrations, but I was wonderring about annotations or Fluent API.

By the way, congrats for the awesome work!

enhancement

Most helpful comment

At this point, I think closing makes sense. If anything changes between now and 3.0, we can always reopen and reconsider at that time.

All 7 comments

I don't think that we do currently, but it looks like Sqlite has support for this in 2.2.

We could probably do something similar too.

/cc @roji @YohDeadfall

Makes sense.

I'm actually going to take an initial pass at this. I'll open a WIP PR in a little while.

Doing this cleanly for 2.2 isn't going to be possible because of https://github.com/aspnet/EntityFrameworkCore/issues/14000. While it's possible to hack something up (i.e. pick up the model annotation in the MigrationsSqlGenerator), it should be possible to simply specify the exact store type as described in the EF Core docs. Give this a try, if this doesn't work please post back here.

Note: I'll still work on completing #719 for automatically setting the column's spatial type correctly (e.g. GEOMETRY (POINT) based on the NTS CLR type.

Similar to #738, on reexamination I'm not sure this really makes sense. Users can explicitly specify the column's store type, including both a type constraint (point vs. linestring) and an SRID. We should consider closing this...

At this point, I think closing makes sense. If anything changes between now and 3.0, we can always reopen and reconsider at that time.

Was this page helpful?
0 / 5 - 0 ratings