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.

  • Twitter
  • Facebook
  • Share/Bookmark
This entry was posted in .* and tagged , , . Bookmark the permalink.

8 Responses to Generated primary key in Entity Framework model from Firebird

  1. Pingback: Firebird News » Generated primary key in Entity Framework model from Firebird

  2. Miroslav Hrázský says:

    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.

  3. cincura.net says:

    Jde to zapsat do komentare i primo do system table, ale jinak prikazem:
    comment on column table.column is ‘#PK_GEN#’

  4. Cesar says:

    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

  5. cincura.net says:

    No. Views don’t have any PK by definition. You have to specify it yourself.

  6. Cesar says:

    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?

  7. cincura.net says:

    Hard to guess without further investigation.

  8. Burton says:

    Cesar,
    Try deleting the entity from the model and then update the model from the database. That’s what I had to do.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>