I have a postgresql database with postGIS and I'm using entity framework with dotconnect 6.7 for postgreSQL.
With the following table in my database:
CREATE TABLE geo
(
the_geom geometry,
id integer NOT NULL,
CONSTRAINT primary_key PRIMARY KEY (id),
CONSTRAINT enforce_srid_geometry CHECK (st_srid(the_geom) = 4326)
)
and running the following code
class Program {
static void Main(string[] args) {
using (test_Model.test_Entities ctx = new test_Model.test_Entities()) {
var geom = new test_Model.geo();
geom.id = 0;
geom.the_geom = DbGeometry.PointFromText("POINT (1 1)", 4326).AsBinary();
ctx.geos.AddObject(geom);
ctx.SaveChanges();
}
}
the following constraint fails in the database
CONSTRAINT enforce_srid_the_geom CHECK (st_srid(the_geom) = 4326)
Curious for what value the database registered, I tried having the following two constraints
CONSTRAINT enforce_srid_the_geom CHECK(st_srid(the_geom) > 4326)
CONSTRAINT enforce_srid_the_geom CHECK(st_srid(the_geom) < 4326)
Neither worked. Since these are integer values being compared, atleast one of the last three queries should have been true.
After a while I found that the following constraint lets me insert something with srid=4326 into the table
st_srid(the_geom) <= 4326)
but it seems to accept everything, both larger and smaller srids, for some reason.
Is this a bug in postgresql, entity framework or dotconnect?
Edit: The query
SELECT st_srid(the_geom) FROM geo WHERE geo.id == 0
returns the srid 0. So, no matter what srid I give specify in entity framework, it appears as 0 in the database. What is going on?
postgresql 6.7
? Doesn't even exist. Or is that dotconnect 6.7? Then what are the Postgres and PostGis versions? – Pugliese