views:

205

answers:

2

I've been following the walkthrough for creating your first WCF RIA Services Application from Microsoft and have encountered a problem when trying to edit and update data using the SubmitChanges() method of the Data Context.

The table being updated has an Identity Specification set in SQL Server 2008 on the 'CourseID' column. However the PRIMARY key is a composite of two other fields.

When using SubmitChanges() the application locks up in the browser an presents an unhandled exception. By handling this exception I managed to get the message: Modifying a column with the 'Identity' pattern is not supported. This is referring to the 'CourseID' column.

Turning identity specification off solves the problem, but I need the auto-incrementing ID. In what way isn't this supported. Or where am I going wrong?

+1  A: 

The database structure is at fault here.

Banford
A: 

As a comment above specifies you need to set the StoreGeneraratedPattern to "Computed".

While you can change this on the Model Designer which changes the value in the CSDL. However for it to work the value also has to be changed in the SSDL. The only way to change this is to modify the XML by hand.

Keep in mind various things like "Update model from database" will regenerate the SSDL... so you have to reapply you changes.

PilotBob

related questions