Reputation: 117
If i use StoreGeneratedPattern="None"
then SaveChanges() throws an Exception. It tries to save an object admin with ID=0
. It does the same for all other objects. The ID
is always 0. If i use StoreGeneratedPattern="Identity"
an Exception is thrown again:
A null store-generated value was returned for a non-nullable member 'AdminId'
I have this column in my Table:
adminid integer NOT NULL DEFAULT nextval('admin.seq_admin'::regclass)
EDIT Is nextval the right command for the autoincrement? Is there IDENTITY
in postgresql?
Upvotes: 0
Views: 304
Reputation: 676
To begin with nextval is the right command for autoincrement. I had the same problem with postgresql, and tired manny different settigns either in ef and pgsql, but the problem gone when I recreated the table and somehow new sequence with 1 at the end (tasktasktitleid_seq1) automatically generated.
EDIT: I got the same problem again so what that's what I did: 1. deleted Id from table. 2. Created new colum of type big serial 3. Opened table properties and added new primary key in constraints tab. After I saved the table, I got my default value for id a new auto-generated sequence and from then on my saves that table flawless..ly
Upvotes: 1