Print Page | Close Window

Modify Primary Key Value

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1261
Printed Date: 14-May-2025 at 10:17pm


Topic: Modify Primary Key Value
Posted By: Markh
Subject: Modify Primary Key Value
Date Posted: 14-May-2009 at 11:03pm
Just using the Learning Units\WinClient-Only\200 Intermediate\Adding and Deleting Entities Example
When I change an order detail (ie Change the Product) and try to save the following exception occurs
 
A referential integrity constraint violation occurred: The property values that define the referential constraints are not consistent between principal and dependent objects in the relationship
 
Is this saying that once a primary key has been created you can not change any of the primary key values!
 
How can you change the OrderDetail to allow the Product to be changed ?
 



Replies:
Posted By: GregD
Date Posted: 15-May-2009 at 6:00pm
Well, now that I think about it, I can see how that would create a problem. We can only find the OrderDetail record we want to update in the database by its primary key value, but there's almost certainly no OrderDetail record that matches the primary key value that our local record now has.

With the database as designed, our only recourse is to create a new OrderDetail record (with the Product we want), copy other property values from the existing record, then delete the existing record.

One more reason why I personally avoid composite keys like the plague.

I'll change the Learning Unit solution to make the Product property read-only.

Greg Dunn
Training & Docs Mgr


Posted By: Markh
Date Posted: 17-May-2009 at 5:43pm
Are there any plans to make Primary Keys updatable within DevForce WinClient ?
 
 



Print Page | Close Window