Issue with spatial types in entity framework, dotconnect for postgreSQL v6.7
Posted: Thu 01 Aug 2013 09:07
I have done database first using the following table with entity framework and dotconncet for postgresql 6.7.
and running the following code the st_srid(the_geom) = 4326 fails.
Is there an alternative approach where the srid data does not disappear (or, is set to 0 before it reaches the database)?
I noticed that with database first approach the type of the geometry data in the model is binary instead of (for example) DbGeometry. I tried to change the type to geometry but then I got the following error
get the following error when I try to change the type of one property in my model to Geometry:
"Member Mapping specified not valid. The type 'Edm.Geometry [Nullable=True, DefaultValue=,SRID=0,IsStrict=False]' of member (...) is not compatible with 'Devart.Data.PostgreSQL.geometry [Nullable=True,DefaultValue=,MaxLength=2147483646,FixedLength=False]' of Member (...)"
isn't there a geometry type on the c# side of things that corrensponds to the Devart.Data.PostgreSQL.geometry?
Code: Select all
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)
)
Code: Select all
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();
}
}
I noticed that with database first approach the type of the geometry data in the model is binary instead of (for example) DbGeometry. I tried to change the type to geometry but then I got the following error
get the following error when I try to change the type of one property in my model to Geometry:
"Member Mapping specified not valid. The type 'Edm.Geometry [Nullable=True, DefaultValue=,SRID=0,IsStrict=False]' of member (...) is not compatible with 'Devart.Data.PostgreSQL.geometry [Nullable=True,DefaultValue=,MaxLength=2147483646,FixedLength=False]' of Member (...)"
isn't there a geometry type on the c# side of things that corrensponds to the Devart.Data.PostgreSQL.geometry?