auto increment/identity column

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
gcutler
Posts: 2
Joined: Mon 04 Mar 2013 16:20

auto increment/identity column

Post by gcutler » Mon 04 Mar 2013 16:29

Hello, I'm having trouble figuring out how to use an auto increment/identity column. I've created the column and the sequence in postgres and set the column's default value to use the sequence. When I do inserts from SQL it works fine. However, when I do an insert from Entity Framework it always inserts a 0 into the id column. I've set the StoreGeneratedPattern to Identity and the .edml file has devart:DefaultValue set to the same sequence that is used in Postgres. Please let me know what I need to do to get Entity Framework to use the values generated by the postgres sequence instead of always using 0.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: auto increment/identity column

Post by Shalex » Tue 05 Mar 2013 14:51

gcutler wrote:I've created the column and the sequence in postgres and set the column's default value to use the sequence.
Please clear the value of devart:DefaultValue (not to use this feature) and set StoreGeneratedPattern to Identity for the property in the SSDL part of the model.

As for the devart:DefaultValue functionality, please refer to http://blogs.devart.com/dotconnect/set- ... faultvalue.

gcutler
Posts: 2
Joined: Mon 04 Mar 2013 16:20

Re: auto increment/identity column

Post by gcutler » Tue 05 Mar 2013 15:07

Ah, I got a bit confused by the way the XML is split up and didn't realize StoreGeneratedPattern gets set in two places. I did what you said and it is now working correctly. Thanks for your help!

gershon
Posts: 1
Joined: Tue 21 Jun 2016 13:45

Re: auto increment/identity column

Post by gershon » Tue 21 Jun 2016 13:58

In SSDL,I have 1 column has StoreGeneratedPattern="Identity" defined and when executing code of Entity Framework it is throwing error as "Syntax error at Returning".
Generated Query : INSERT INTO table (col1,col2,col3)
VALUES ($1, $2, $3)
RETURNING col4

Can you please help me both of you?
Let me know if you require more details.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: auto increment/identity column

Post by Shalex » Wed 22 Jun 2016 17:04

We cannot reproduce the problem in our environment at the moment. Please send us a small test project with the corresponding DDL script (if needed) for reproducing.

In case of >2MB attachment, we recommend either using some file exchange server (send us the corresponding link) or uploading a test project to our FTP server (the credentials will be provided by email request).

Post Reply