Page 1 of 1

Postgis problem

Posted: Mon 02 Sep 2013 18:08
by vkorn
Hello,

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. 1.13.0.0
Postgis 2.0

Please advise where I should dig further?

Re: Postgis problem

Posted: Wed 04 Sep 2013 18:05
by vkorn
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?

Re: Postgis problem

Posted: Fri 06 Sep 2013 18:04
by Shalex
We recommend setting SpartialServiceType and other EF options either in a static constructor of the context or in *.config:

Code: Select all

<configuration>
  <configSections>
       <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" />
  </configSections>
  <Devart.Data.PostgreSql.Entity xmlns="http://devart.com/schemas/Devart.Data.PostgreSql.Entity/1.0">
    <SpatialOptions SpatialServiceType="NetTopologySuite"/>
  </Devart.Data.PostgreSql.Entity>
...