This is a migrated thread and some comments may be shown as answers.

voa_keygen problem

13 Answers 621 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
regis
Top achievements
Rank 1
regis asked on 06 Aug 2010, 04:28 PM
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

13 Answers, 1 is accepted

Sort by
0
Steve
Top achievements
Rank 1
answered on 06 Aug 2010, 07:39 PM
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.
0
regis
Top achievements
Rank 1
answered on 06 Aug 2010, 08:17 PM
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
0
Steve
Top achievements
Rank 1
answered on 06 Aug 2010, 08:40 PM
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.
0
Accepted
Damyan Bogoev
Telerik team
answered on 09 Aug 2010, 05:11 PM
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
0
regis
Top achievements
Rank 1
answered on 12 Aug 2010, 04:45 PM
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.
0
Steve
Top achievements
Rank 1
answered on 12 Aug 2010, 04:51 PM
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."
0
Damyan Bogoev
Telerik team
answered on 13 Aug 2010, 03:43 PM
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
0
Mike Pugh
Top achievements
Rank 1
answered on 25 Aug 2010, 02:06 PM
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.
0
Zoran
Telerik team
answered on 26 Aug 2010, 04:50 PM
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
0
Markus
Top achievements
Rank 2
answered on 16 Nov 2010, 02:50 PM
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
0
Ray
Top achievements
Rank 1
answered on 26 Apr 2011, 06:25 PM
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.
0
Michael
Top achievements
Rank 1
answered on 08 Nov 2012, 12:28 AM
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.
0
Ivailo
Telerik team
answered on 12 Nov 2012, 10:33 AM
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.
Tags
General Discussions
Asked by
regis
Top achievements
Rank 1
Answers by
Steve
Top achievements
Rank 1
regis
Top achievements
Rank 1
Damyan Bogoev
Telerik team
Mike Pugh
Top achievements
Rank 1
Zoran
Telerik team
Markus
Top achievements
Rank 2
Ray
Top achievements
Rank 1
Michael
Top achievements
Rank 1
Ivailo
Telerik team
Share this question
or