voa_keygen problem

14 posts, 1 answers
  1. regis
    regis avatar
    44 posts
    Member since:
    May 2009

    Posted 06 Aug 2010 Link to this post

    Hi everyone,

    I am trying to use the ORM against my database on sql server 2005.

    I followed some tutorials using Northwind database and end up witout any problem. but when I create a model from my database and try to add an entity to a table I get a voa_keygen error.

    I think it's a problem with my database configuration but can't find which one.

    I connect using a a user that is dbowner. Should my user need to be something else.

    Thanks for any help

    Regis
  2. Steve
    Steve avatar
    11 posts
    Member since:
    Jan 2010

    Posted 06 Aug 2010 Link to this post

    I had this problem a couple days ago and Telerik's support was a huge help. It stemmed from the fact that I was trying to query a view. View's have no primary key and this caused a problem for the ORM. If you are using the Domain Model approach, find the table or view in the domain model. Select the column(s) that you would like to be part of the primary key and in the properties for that column set the Identity field equal to true. If it is a table you may want to make sure you specified primary keys on the table inside the database. Hope that helps.
  3. DevCraft banner
  4. regis
    regis avatar
    44 posts
    Member since:
    May 2009

    Posted 06 Aug 2010 Link to this post

    Hi Steve,

    Thanks for your reply.

    I am not dealing with a view.

    As per your advice, I checked some of the tables (there are more than 40 tables in the schema). the primary key is defined in the database. in the model the primary key are correctly displayed with the small icon and identity it set in properties.

    Everything seem all right on this side.

    Thank you

     Regis
  5. Steve
    Steve avatar
    11 posts
    Member since:
    Jan 2010

    Posted 06 Aug 2010 Link to this post

    Hmmmm. Interesting. Well I know the problem will occur regardless of whether or not you are running an active query on the specific table or view that is causing the issue. As long as it is in the Domain Model it may be causing the issue. If you do not have any views specified in your domain model and all of your tables have some kind of unique key then I am stumped as to a solution.
  6. Answer
    Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 09 Aug 2010 Link to this post

    Hi regis,

    The problem usually arises when a class uses the default identity mechanism (the HIGHLOW key generator) but the required voa_keygen table is missing. This error is most commonly met when the user has reverse mapped some views on the diagram and has not set any primary keys for them. In that situation, OpenAccess considers this classes are using internal identity and the HIGHLOW key generator which is used for internal identity mechanism.

     There are two ways to avoid this error:

    1. You can set one of the properties of the classes that have no identity members, to be the identity member for the class. Please make sure that the values for this member are unique in the database though.

    2. If you want to use the HIGHLOW key generator you will have to create the voa_keygen table in the database. You could use the Update Schema from Model wizard (inside the Visual Designer) to generate and execute a DDL script for the missing table. 
    Run the wizard from the Model Schema Explorer by right-clicking on the root node and choosing the Update Schema from Model menu option. 
    Additional information regarding the wizard can be found under the following help section.


    All the best,
    Damyan Bogoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. regis
    regis avatar
    44 posts
    Member since:
    May 2009

    Posted 12 Aug 2010 Link to this post

    Thanks Damyan for your reply.

    I think I find the reason why i get this error. I discover that for some obscure reasons I have several tables that don't have a primary key.

    even if the tables i was dealing with all have a PK and correct FK apparently the fact that others table don't have a primary key affect all kind of insert.

    I redo a model with just the tables i need instead of grabbing the whole schema and the insert works perfectly.

    Thank you for inlighting me.
  8. Steve
    Steve avatar
    11 posts
    Member since:
    Jan 2010

    Posted 12 Aug 2010 Link to this post

    Regis, 
      Glad to see you were to get it working. I mentioned that in my previous post that if you had any table in the domain model that did not have a primary key it would cause the entire solution to fail, even if the tables you were working with did have correct primary keys.

    "Well I know the problem will occur regardless of whether or not you are running an active query on the specific table or view that is causing the issue. As long as it is in the Domain Model it may be causing the issue."
  9. Damyan Bogoev
    Admin
    Damyan Bogoev avatar
    581 posts

    Posted 13 Aug 2010 Link to this post

    Hi Steve,

    This is not an issue in the product. When the Identity Mechanism of a specific type is not explicitly set, the default setting is used which is HIGHLOW key generator. When the HIGHLOW key generator mechanism is being used, OpenAccess requires the voa_keygen table to be present in the database as that is the table where it preserves the last used id values for each table that has this identity mechanism.

    When you first initialize a context or create a Database object as an entry point to OpenAccess, the runtime collects all of the metadata required in order to operate correctly with a certain persistent model. If there are problems with the metadata, OpenAccess throws exception regardless of whether you have accessed the exact entity that causes the invalid metadata or not.

    Sincerely yours,

    Damyan Bogoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Mike Pugh
    Mike Pugh avatar
    1 posts
    Member since:
    Apr 2008

    Posted 25 Aug 2010 Link to this post

    Just a note on the documentation - I ran into this and did a search on the help file and it came back with a list of various identity mechanisms (hilow, guid, etc) and the documentation referred to an option "None" which just isn't available in the properties pane. I'm doing a lot of queries off of views from my db and I was hoping to just tell it to use "None" but couldn't, anyway, just set one of the columns to be the identity field and now all is happy. But I'd recommend updating the docs with this info.
  11. Zoran
    Admin
    Zoran avatar
    534 posts

    Posted 26 Aug 2010 Link to this post

    Hi Mike Pugh,

     Can you point to us for a specific topic that you referred in you previous letter. We will surely update the documentation, it seems it is a leftover from some older help topic from the old wizards mapping approach. In the visual designer it is enough to leave the Identity mechanism to "Default" and just set a particular member as an Identity member - that solves the issue for this scenario.

    Best wishes,
    Zoran
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Markus
    Markus avatar
    205 posts
    Member since:
    Nov 2005

    Posted 16 Nov 2010 Link to this post

    Hi there

    Had the same problem. Damyan was right on the spot. I did not have a primary key for my table. As soon as I set it, it worked.

    Regards and thanks Markus
  13. Ray
    Ray avatar
    5 posts
    Member since:
    Mar 2011

    Posted 26 Apr 2011 Link to this post

    This thread saved me lots of time.  I added a new table to my diagram and my previous code stopped working with this voa_keygen error.  After reading the thread, I went back and discovered that my latest table did indeed lack an identity field.  I set the proper field and my code resumed working.

    Thanks, guys!

    -Ray.
  14. Michael
    Michael avatar
    19 posts
    Member since:
    Oct 2011

    Posted 07 Nov 2012 Link to this post

    I think the VS tools need to help identify offending tables given the frequency of this issue and how nasty it can be when it occurs (like in my case where I have MANY views).

    I'm about ready to turn back to EF because of the effort this is taking.
  15. Ivailo
    Admin
    Ivailo avatar
    318 posts

    Posted 12 Nov 2012 Link to this post

    Hi Michael,

    Thank you for the feedback.

    We understand that this error can be very frustrating. For that reason we have created a validation rule that will help you identify all of those cases, and a validation action that can fix them for you. I am not sure if we can actually make this process more automated, as in the absence of a primary key column if would be risky for OpenAccess ORM to try guessing the best option - it is much better to leave that choice to you. As for the specific case of the database views, we do plan to improve the process of reading them from the database so that we can have an idea what should the identity be. However, I cannot yet provide you with a time frame for releasing that feature.

    What we have done recently for Q3 2012 (already live) is to change the warning that a persistent type doesn't have a primary key to an error, which means that even on the Visual Designer surface you know that the model will have serious problems during runtime. 

    I hope that helps. 


    Kind regards,
    Ivailo
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Back to Top
DevCraft banner