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

The object name 'voa_keygen' is invalid ???

15 Answers 418 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Allen
Top achievements
Rank 1
Allen asked on 05 Dec 2014, 01:42 AM
Hello, Admin.
Very strange, don't know why, occasionally will throw an exception:
"The object name 'voa_keygen' is invalid."
All the tables have a primary key.
It looks like the intermittent seizures, be rather baffling.....

15 Answers, 1 is accepted

Sort by
0
Doroteya
Telerik team
answered on 09 Dec 2014, 01:59 PM
Hi Allen,

The cause for this error lies in the fact that Telerik Data Access needs to associate the persistent classes with primary keys, and by design the persistent classes mapped to views do not have primary keys. To resolve the situation you can apply either one of the solutions suggested in this documentation article.

Do let us know if you need further information.


Regards,
Doroteya
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Allen
Top achievements
Rank 1
answered on 10 Dec 2014, 06:08 AM
Hi,Doroteya.
Each table has a primary key..
Thanks.
0
Doroteya
Telerik team
answered on 11 Dec 2014, 02:02 PM
Hi Allen,

I am sorry you are still experiencing issues.

The error appears only when the model on your side contains a persistent class without a primary key property. Usually, such a scenario occurs, when the model contains views (in addition to the tables). Both the tables and the views from the database are mapped to persistent classes from Data Access perspective, but since the views do not have primary keys in the database, their corresponding persistent classes have no primary key properties.

For better understanding of the situation, you can take a look of the view-example.png screenshot. Note that TableId in MyTable is marked as a primary key, while TableId in MyView is not. For your convenience and for an easier way to find such cases, our validation framework will display both an error and a warning in Error List.

In this connection, I strongly recommend to you to review the content of Error List for such errors and warnings.

To nominate a given property for a primary key, you need to select it, and to set the Identity property to True, as demonstrated on view-primary-key.png.

Once you do that, you need to save (Ctrl + S) the model before running the application for a test.

I hope this helps. Let us know, if you are still experiencing the error.



Regards,
Doroteya
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Allen
Top achievements
Rank 1
answered on 12 Dec 2014, 01:37 AM
Hi,Doroteya.
First,sincerely thank you for your reply...
You say I'm know all..
The crux of the matter is not here.
Because this code: currentMetadataContainer.UniqueIdGenerator.CreateTable = true;
Now I have solved, is that another admin help me solved!
In OpenAccessContext derived class, add a method:
public void UpdateSchema()
{
    var handler = this.GetSchemaHandler();
    string script = null;
    try
    {
        script = handler.CreateUpdateDDLScript(null);
    }
    catch
    {
        bool throwException = false;
        try
        {
            handler.CreateDatabase();
            script = handler.CreateDDLScript();
        }
        catch
        {
            throwException = true;
        }
        if (throwException)
            throw;
    }
 
    if (string.IsNullOrEmpty(script) == false)
    {
        handler.ExecuteDDLScript(script);
    }
}
And in the Global.asax.cs's Application_Start() call UpdateSchema().

0
Doroteya
Telerik team
answered on 16 Dec 2014, 09:38 AM
Hello Allan,

Thank you for getting back to us. I am glad that currently things are working on your side.

Let me confirm that, indeed an update of the database schema is necessary in order to consume the sequential guids generated by Telerik Data Access. During this update, the voa_keygen table will be created in the database, so that it is always possible for Data Access to know the last generated value.

Let us know, if you need further information.


Regards,
Doroteya
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Allen
Top achievements
Rank 1
answered on 17 Dec 2014, 08:42 AM
New problems coming.
From this picture, you can clearly see the three view fields are not all primary key fields.
Therefore, it is not possible to set a primary key.
So, what should I do?
Otherwise an exception will be thrown.
0
Allen
Top achievements
Rank 1
answered on 17 Dec 2014, 09:10 AM
Cannot upload pictures in the Forum, really too much trouble ...Pictures are here.
0
Doroteya
Telerik team
answered on 18 Dec 2014, 02:12 PM
Hello Allen,

In such situations, the best approach is to make a combination of the existing properties, that will uniquely identify each object returned by the view. For example: you can take a look at the attached screenshot (views-with-multiple-primary-key-properties.png). Note that there are cases when you may need to mark all the properties as primary keys and this is completely fine with Data Access, as long as the combination provides unique identification of the returned objects.

I hope this helps. Let us know how are the things on your side. 

Regards,
Doroteya
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Allen
Top achievements
Rank 1
answered on 19 Dec 2014, 03:03 AM
Hello Doroteya.
It really won't have any problems?
After you set the primary key, duplicate values will be how to deal with by ORM? such as name fields.
I guess I have to do a little test.
In any case, really thanks for your help.
0
Doroteya
Telerik team
answered on 19 Dec 2014, 11:43 AM
Hi Allen,

Indeed, when you work with views such a manual marking of a combination of properties is fine with Data Access. The idea is Data Access to be able to distinguish between the different objects returned by the view (and this fictitious selection helps exactly for that) . 

In case you have something specific are a consideration in mind, let me know and we will provide you with details.

I hope this helps.



Regards,
Doroteya
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Allen
Top achievements
Rank 1
answered on 20 Dec 2014, 02:41 AM
Hello, Doroteya.
Test result is TDA ORM filter duplicates, this is not what I want.
 I do not wish to filter out these duplicate values.
Does I have to use the most stupid ADO API?
Thanks
0
Allen
Top achievements
Rank 1
answered on 20 Dec 2014, 03:06 AM
Hello, Doroteya.
Test results is a little funny.
var query = ContextFactory.GetContextPerRequest().V_TestView_Users;
var test_user = query.Where(t => SqlMethods.Like(t.Name, "Chadwick Potter")).ToArray();
//Test Result: 10 records
//Return result:
//Chadwick Potter
//Chadwick Potter
//Chadwick Potter
//Chadwick Potter
//Chadwick Potter
//Chadwick Potter
//Chadwick Potter
//Chadwick Potter
//Chadwick Potter
//Chadwick Potter
 
var test_user2 = query.Where(t => t.Name == "Chadwick Potter").ToArray();
//Test Result: Only one record
//Return result:
//Chadwick Potter
I don't get it...
0
Doroteya
Telerik team
answered on 22 Dec 2014, 10:29 AM
Hi Allen,

The behaviour you observe is expected. Data Access will filter duplicates, when the chosen combination of primary key properties does not provide unique distinction between the returned objects. In you case, it is possible to retrieve everything with the help of a little modification in the view. This modification includes adding a row number for each row in the view result and nominating the row number column as a primary key property in the model. The final result will look in your model as demonstrated in the attached screenshot (row-number-added.png). The implementation steps are as follows:

1. Open the view for edit (if you are using MS SQL Server and Management Studio, simply right-click on the name of the view in Object Explorer and select Design).
2. Using the row_number() function, add a new column in the shape of the view
3. Save the view (Management Studio usually complaints that it cannot display the performed change. You can safely disregard the warnings and click the OK buttons).
4. Update the view with the changes using the Update From Database wizard. The steps are described here in details.
5. In the designer, set the newly added row property as a primary key property for the view.
6. Save the model.

At this point Data Access will return every row provided by the view.

I hope this helps. Let us know if you need further assistance.


Regards,
Doroteya
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
0
Allen
Top achievements
Rank 1
answered on 26 Dec 2014, 09:28 AM
Hi, Doroteya.
I have thought about this method, but it is very easy to cause a full table scan.
Thanks.

Merry Christmas...
^_^
0
Viktor Zhivkov
Telerik team
answered on 29 Dec 2014, 09:20 AM
Hi,

If you have selected to have Name as primary key the difference in behavior is expected.
Telerik Data Access will take a special shortcut if you are filtering by the primary key. In that case you will get a single result even if there are many more records that are matching your filter criteria.
To get more than one row in the results you may use the following code:
var query = ContextFactory.GetContextPerRequest().V_TestView_Users;
var test_user = query.Where(t => t.Name.StartsWith("Chadwick Potter")).ToArray();


Regards,
Viktor Zhivkov
Telerik
 
OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
 
Tags
Data Access Free Edition
Asked by
Allen
Top achievements
Rank 1
Answers by
Doroteya
Telerik team
Allen
Top achievements
Rank 1
Viktor Zhivkov
Telerik team
Share this question
or