Changes are not possible if the primary key fields are not visible.
Please specify the id and version fields in the persistent attribute.
[Telerik.OpenAccess.Persistent(IdentityFied="id", VersionField="version"]
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: Telerik.OpenAccess.Exceptions.UnsupportedException: Changes are not possible if the primary key fields are not visible.
Please specify the id and version fields in the persistent attribute.
[Telerik.OpenAccess.Persistent(IdentityFied="id", VersionField="version"]
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
|
10 Answers, 1 is accepted
If you are using visible id fields (pls. check the Persistent attribute) this error is because of an older OpenAccess version.
The dataKeyNames property of the grid is not set correctly. With the latest OpenAccess version please rebind the datasource to the grid and it should work.
Regards,
Jan Blessenohl
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I have the same problem as above discribed.
I have the Q3 2008 products of OA and RadControls. Actuality should not be the problem.
my code:
------------ OA section
//Generated by Telerik OpenAccess
[Telerik.OpenAccess.Persistent(IdentityField = "kId")]
public partial class Kunde
{
private int kId; // pk
private bool kAktiv;
private DateTime? kAktivBis;
....
------------
... as seen in the demos, i have to use advanced-databinding ...
------------ ASP.NET Section
...
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
RadGridAccounts.NeedDataSource += new Telerik.Web.UI.GridNeedDataSourceEventHandler(RadGridAccounts_NeedDataSource);
}
}
protected void RadGridAccounts_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
RadGridAccounts.DataSourceID = "OpenAccessDataSource1";
}
}
------------
The id field is visible, but there is no version field in the table.
Any ideas?
TIA!
Markus
The problem with the missing version field is that the concurrency control will not work.
Is it a big problem to add it?
Greetings,
Jan Blessenohl
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thanks for your reply.
I added an Version-field into the table and reverse mapped it again.
The new field "kVersion" was added into app.config and reversemapping.config, but neither in Kunde.cs nor Kunde.Telerik.OpenAcess.cs.
I can compile this, but the runtime-error when i try the update button of the grid remains the same.
If i manually add the VersionField [Telerik.OpenAccess.Persistent(IdentityField="kId", VersionField="kVersion")] in Kunde.Telerik.OpenAccess.cs , i can't compile anymore:
Fehler 119 OpenAccess Error: The VersionField specified is not declared on this class. [class=DAL.Kunde] [field=kVersion] ...\DAL\Kunde.cs 9
Any hints?
Regards
Markus
Did you regenerate the respective class?
Can you send me your reversemapping.config with the info which node has the problem?
Sincerely yours,
Jan Blessenohl
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Yes, I regenerated this class.
Here is the reversemapping.config. I removed the classGenerator Info of the other, unused tables.
------------------
<?xml version="1.0" encoding="UTF-8"?>
<openaccess>
<classGenerator defaultPackageName="DAL">
<table name="'Kunde'" type="1" locked="False">
<column name="K_Id" isPk="True" isAutoInc="True" adoType="4" sqlType="int" length="0" isNull="False" />
<column name="K_Version" isPk="False" isAutoInc="False" adoType="4" sqlType="int" length="0" isNull="False" />
<column name="K_AktivVon" isPk="False" isAutoInc="False" adoType="93" sqlType="datetime" length="0" isNull="True" />
<column name="K_AktivBis" isPk="False" isAutoInc="False" adoType="93" sqlType="datetime" length="0" isNull="True" />
<column name="K_Aktiv" isPk="False" isAutoInc="False" adoType="-7" sqlType="bit" length="0" isNull="False" />
<column name="K_System" isPk="False" isAutoInc="False" adoType="-7" sqlType="bit" length="0" isNull="False" />
<column name="K_Lieferant" isPk="False" isAutoInc="False" adoType="-7" sqlType="bit" length="0" isNull="False" />
<column name="K_Demo" isPk="False" isAutoInc="False" adoType="-7" sqlType="bit" length="0" isNull="False" />
<column name="K_MutDatum" isPk="False" isAutoInc="False" adoType="93" sqlType="datetime" length="0" isNull="False" />
<column name="K_B_Id" isPk="False" isAutoInc="False" adoType="4" sqlType="int" length="0" isNull="True" />
<class name="Kunde" check="-1573426966" generated="True">
<field name="kId" type="1" isPK="True" isAutoInc="True" column="K_Id" valueType="System.Int32" />
<field name="kAktiv" type="1" isPK="False" column="K_Aktiv" valueType="System.Boolean" />
<field name="kAktivBis" type="1" isPK="False" column="K_AktivBis" valueType="System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" />
<field name="kAktivVon" type="1" isPK="False" column="K_AktivVon" valueType="System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" />
<field name="kBId" type="1" isPK="False" column="K_B_Id" valueType="System.Nullable`1[[System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" />
<field name="kDemo" type="1" isPK="False" column="K_Demo" valueType="System.Boolean" />
<field name="kLieferant" type="1" isPK="False" column="K_Lieferant" valueType="System.Boolean" />
<field name="kMutDatum" type="1" isPK="False" column="K_MutDatum" valueType="System.DateTime" />
<field name="kSystem" type="1" isPK="False" column="K_System" valueType="System.Boolean" />
<field name="kVersion" type="1" isPK="False" isVersion="True" column="K_Version" valueType="System.Int32" />
</class>
</table>
</classGenerator>
<options>
<sourcegeneration partial="True" />
<allSchemata>
<schemata name="(default)" />
</allSchemata>
<usedSchemata>
<schemata name="(default)" />
</usedSchemata>
<mapping>
<identity explicitIDClass="False" />
</mapping>
</options>
</openaccess>
------------------
The new field I have inserted for the version is the "K_Version" field.
This version field don't appear in the class files, as mentioned before.
Kind regards,
Markus
We have found the problem. It has to do with the version settings. After a first look I think the complete setting is not working. As workaround pls. remove the version checkbox check and generate all. Then open the forward mapping wizard and set the field as version field again.
The problem is, that you have to make it whenever you regenerate this source.
Best wishes,
Jan Blessenohl
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Thanks for your answer.
Unfortunatly the workaround didn't work. The same error is still there [visible in a Javascript-Error window].
I have no time to follow this thread here any longer. It was not the way I wanted to implement the whole thing. It was just my first approach into RADControls and OA-ORM, and to follow the steps I saw on a demo Telerik-Video, and see what should be possible. (Sorry, i'm not satisfied with the result.)
I'll try now another approach. No more autogenerated columns and autogenerated update (within the grid). I have to verify the datas before writing to the db anyway. My other test with manualy update the OA-generated class worked (so far), that's the way i wanna go now.
Thanks and kind regards,
Markus
I got this error using a new "RadControls Web Application" project. I could add a record, but could not query; the error above.
When I added a standard WebApplication project it all works fine. No clue why, all was the same (refs) and querying code. I Tried console also for testing and also no problems, but a "RadControls Web Application" project would just not go.
Erik
Can you provide some more details of the error. What are you trying to achieve and what is the exception you get? Are you using the the 'Classic' product where your mapping is in the app.config file or are you using a domain model (.rlinq file)?
All the best,
Ady
the Telerik team