Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am trying to save a Point Type into Postgresql I have tried this way. (Db table Model definition)

 public NpgsqlPoint Position { get; set; }

I set the Object with this method

  posData.Position = new NpgsqlPoint (34.3244,23.2344);

But when i call .SaveChanges on the dbContext i get an exception of Not Null Constraint Violation , so i guess EF is trying to insert a null.

I have debuged the posData.Position before entry and the object contains proper data.

I have searched google but i didn't find any example or someone having the same problem.

Any Clues?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

I Posted the question in Npgsql Development forum , and got my answer.

NpgSqlPoint type is not yet Supported by EF due to Entity Framework Data type Restriction.

Seems they are still working on this one.

share|improve this answer
add comment

It looks like NpgsqlPoint makes a PostgreSQL point type. This is not the same as a POINT geometry type used by the PostGIS Extension (e.g., geometry(Point, 4326)).

To make a PostGIS geometry, you will need x, y and srid (spatial reference ID; e.g. see http://spatialreference.org/). These can be used with a ST_MakePoint geometry constructor, and ST_SetSRID to establish the spatial reference. For example, here's a parameterized command:

SELECT ST_SetSRID(ST_MakePoint(:long:, :lat:), 4326)

which assumes a WGS84 coordinate (SRID=4326).

share|improve this answer
    
Yes I am Actually Trying to insert a normal postgres "point" type. When i make the variable "String" and pass "12.5454,41.1215" for example the point gets saved successfully . But then i have problem reading the point as string from Entity Framework which returns just the class name as value. –  Anestis Kivranoglou Jul 15 '13 at 10:58
    
Ok, the postgis tag suggested that you were using PostGIS. –  Mike T Jul 15 '13 at 23:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.