Generated primary key in Entity Framework model from Firebird
Firebird doesn’t have identity/autoincrement columns like i.e. MS SQL or MySQL. Firebird has concept of generators/sequences (as know i.e. in Oracle). This is more powerful concept, but comes also with drawbacks, because you can say for sure, whether the column values is generated or not. This is causing problems, if you set StoreGeneratedPattern in your model manually and then updated model from database – it’s lost. Because this can be big pain in the ass, FirebirdClient can now report the column as “Identity” if you give it little help.
If you put into comment of column #PK_GEN#, then FirebirdClient will report it as generated primary key, resulting in StoreGeneratedPattern to be set to “Identity”. Hence you don’t have to every time manually change the model and easily use automatic fetching of the value from database when saving changes. If you wanna test it, grab build from weekly builds.



There's 8 Comments So Far
October 8th, 2009 at 13:32
Zdravim
asi som trochu natvrdly ale vobec netusi co sa presne mysli pod tymto
“…put into comment of column…” Pokusal som sa to dat do
RDB$DESCRIPTION v tbl RDB$RELATION_FIELDS ale asi to nebude ono. Mozes
mi pls poradit? Vdaka.
October 8th, 2009 at 13:37
Jde to zapsat do komentare i primo do system table, ale jinak prikazem:
comment on column table.column is ‘#PK_GEN#’
June 4th, 2010 at 12:09
I wonder if there’s any similar workaround to solve the problem of firebird views not being mapped correctly into the edmx model. The edmx designer is unable to infer a primary key of the views of my firebird data base. Any Ideas?
thanks in advance
June 4th, 2010 at 12:10
No. Views don’t have any PK by definition. You have to specify it yourself.
June 7th, 2010 at 13:08
Thanks for your answer… I guessed I had to specify PK views manually.
By the way. I tried the ‘#PK_GEN#’ workaround and it didn’t work. The storegeneratedpattern attribute is still missing every time I update the model.
Does it have to be something like this, doesn’t it?
COMMENT ON COLUMN INVOICE.ID IS
‘#PK_GEN#’;
Am i doing anything wrong?
June 7th, 2010 at 13:59
Hard to guess without further investigation.
July 15th, 2010 at 19:59
Cesar,
Try deleting the entity from the model and then update the model from the database. That’s what I had to do.
Who Linked To This Post?
Share your thoughts, leave a comment!