Telerik Data Access Runtime requires each object to be associated with an unique identifier. As it is described by this documentation article
, this means that primary keys should be set even for mapped views
. The most probable reason for the issue you are experiencing is that the primary key you have selected for the view contains one or more nullable columns. When choosing columns that will be part of the primary key of a view it is recommended to follow these rules:
- Choose a combination of columns that will uniquely identify each row in the view (duplicates should not occur).
- Choose a combination of not nullable columns in order to avoid the issue you described.
You could make sure that all columns you chose to compose a primary key are not nullable
using the Visual Designer
in the following way:
1. Open Model Schema Explorer
2. Locate and expand the view.
3. Select the column and press F4
to open the Property Window
should be set to false
Alternatively If such set of columns cannot be chosen it is possible to introduce a new unique column in the view. For example it could represent the row numbers in the view. When the view is mapped this column should be chosen as a primary key. To demonstrate the approach of creating a view with row numbers (as FakeID
) column the following code snippet uses the Northwind
row_number() over (
FakeID, p.ProductName, s.ContactName
p.SupplierID = s.SupplierID
Should you have any further questions, do not hesitate to contact us again.
OpenAccess ORM is now Telerik Data Access
. For more information on the new names, please, check out the Telerik Product Map