Postgis problem

Postgis problem

Postby vkorn » Mon 02 Sep 2013 18:08


I'm trying to use your provider with postgis, I've read all the documentation and followed every step I found, but I'm not able to make it works.
I'm using POCO object for some MyTable which has column GisPoint created as
Code: Select all
ALTER TABLE "MyTable " ADD COLUMN "GisPoint" geometry(POINT,4326);

Then, I have MyTable class with property
Code: Select all
public DbGeography GisPoint { get; set; }

Using config I'm setting up engine
Code: Select all
PgSqlEntityProviderConfig config = PgSqlEntityProviderConfig.Instance;
config.SpatialOptions.SpatialServiceType = SpatialServiceType.NetTopologySuite;

New value for point is generating like
Code: Select all
GisPoint = DbGeography.PointFromText(string.Format("POINT({0} {1})", response.NmeaRmcMessage.Longitude, response.NmeaRmcMessage.Latitude), 4326)

While trying to save data I'm getting
"NetTopologySuite spatial service provider value checking failed. Unexpected provider value type 'Microsoft.SqlServer.Types.SqlGeography'."

NetTopologySuite is v.
Postgis 2.0

Please advise where I should dig further?
Posts: 2
Joined: Mon 02 Sep 2013 17:55

Re: Postgis problem

Postby vkorn » Wed 04 Sep 2013 18:05

OK, I've found the problem. It was because SpartialServiceType is setting up after object construction. But it's strange, why not to do data-mapping when data submitting for save? Or it's because DbGeometry uses DbSpatialServices.Default for data constructing?
Posts: 2
Joined: Mon 02 Sep 2013 17:55

Re: Postgis problem

Postby Shalex » Fri 06 Sep 2013 18:04

We recommend setting SpartialServiceType and other EF options either in a static constructor of the context or in *.config:

Code: Select all
       <section name="Devart.Data.PostgreSql.Entity"
      type="Devart.Data.PostgreSql.Entity.Configuration.PgSqlEntityProviderConfigurationSection, Devart.Data.PostgreSql.Entity, Version=6.8.322.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
  <Devart.Data.PostgreSql.Entity xmlns="">
    <SpatialOptions SpatialServiceType="NetTopologySuite"/>
Devart Team
Posts: 7660
Joined: Thu 14 Aug 2008 12:44

Return to dotConnect for PostgreSQL