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.
Pingback: Firebird News » Generated primary key in Entity Framework model from Firebird
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.
Jde to zapsat do komentare i primo do system table, ale jinak prikazem:
comment on column table.column is ‘#PK_GEN#’
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
No. Views don’t have any PK by definition. You have to specify it yourself.
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?
Hard to guess without further investigation.
Cesar,
Try deleting the entity from the model and then update the model from the database. That’s what I had to do.