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

Problem setting Identity for Databse View

3 Answers 94 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.
Jeff Clark
Top achievements
Rank 1
Jeff Clark asked on 15 Apr 2011, 03:43 PM
I am trying to use the Domain Model of OpenAccess ORM 2011 Q1 release.

I have a bunch of views that I want to use to query from. Since views do not have a primary key I have to either set a primary key in the rlinq Designer or make use of the voa_keygen table.  Neither of these methods are working for me.

voa_keygen table Method
If I use the voa_keygen table method, I get a yellow screen of death error with 'Invalid column name 'tablename_id' 

This column of course does not exist in the view; so, Why is it trying to use this column?

Primary Key Method
More importantly, I would prefer to just set a primary key.  But when I right click on the entity and click 'edit table', click the Identity checkbox next to the appropriate column(s) and click ok, nothing happens. If I go back to the 'Edit Table' dialog box the identity columns are not checked. (They remain checked for entities created form tables, but not entities created from views).

Is this the appropriate way to create a primary key? If yes, why doen't it work? If no, what is the appropriate way?

I can get the views to work if I edit the generated code and add IsPrimaryKey=true to the Column property of the appropriate column, but since this is generated code my changes are removed whenever the code is regenerated.

Thank you for your help.

3 Answers, 1 is accepted

Sort by
0
Jeff Clark
Top achievements
Rank 1
answered on 20 Apr 2011, 03:27 PM
Any help would be appreciated, thanks.
0
Accepted
Alexander
Telerik team
answered on 20 Apr 2011, 04:39 PM
Hello Jeff Clark,

The "voa_keygen" approach is the OpenAccess' mechanism for handling identities internally. In such cases OpenAccess expects that a column with name "tablename_id". Since you do not have such columns in the views this approach cannot be used.

The correct way to set a primary key for a class is actually to set one (or more) of its properties as identity. It is not required that the column mapped to this property is a primary key column. So all you have to do is select in the diagram the property that you want to be an identity and set its Identity property to True from the Properties pane (press F4 to open it). After doing this a small key should appear in the icon of the identity member.
I hope that helps.

Kind regards,
Alexander
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
Jeff Clark
Top achievements
Rank 1
answered on 20 Apr 2011, 04:53 PM
That works.  Thank you very much.
Tags
General Discussions
Asked by
Jeff Clark
Top achievements
Rank 1
Answers by
Jeff Clark
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or