auto increment/identity column
auto increment/identity column
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.
Re: auto increment/identity column
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.gcutler wrote:I've created the column and the sequence in postgres and set the column's default value to use the sequence.
As for the devart:DefaultValue functionality, please refer to http://blogs.devart.com/dotconnect/set- ... faultvalue.
Re: auto increment/identity column
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!
Re: auto increment/identity column
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.
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.
Re: auto increment/identity column
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).
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).