auto increment/identity column

auto increment/identity column

Postby 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.
gcutler
 
Posts: 2
Joined: Mon 04 Mar 2013 16:20

Re: auto increment/identity column

Postby 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-identity-and-computed-properties-in-entity-framework-without-triggers.html#defaultvalue.
Shalex
Devart Team
 
Posts: 7793
Joined: Thu 14 Aug 2008 12:44

Re: auto increment/identity column

Postby 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!
gcutler
 
Posts: 2
Joined: Mon 04 Mar 2013 16:20

Re: auto increment/identity column

Postby 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.
gershon
 
Posts: 1
Joined: Tue 21 Jun 2016 13:45

Re: auto increment/identity column

Postby 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).
Shalex
Devart Team
 
Posts: 7793
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL