prathmanu
prathmanu

Reputation: 93

Error The property 'xxxx' is part of the object's key information and cannot be modified in WCF RIA service

When I try to update the following error message shows up.

The property 'ID' is part of the object's key information and cannot be modified.

   at System.Data.Objects.EntityEntry.CompareKeyProperties(Object changed)
   at System.Data.Objects.EntityEntry.ApplyOriginalValuesInternal(IEntityWrapper wrappedOriginalEntity)
   at System.Data.Objects.EntityEntry.ApplyOriginalValues(Object originalEntity)
   at System.ServiceModel.DomainServices.EntityFramework.ObjectContextUtilities.AttachAsModifiedInternal[T](T current, T original, ObjectContext objectContext)
   at System.ServiceModel.DomainServices.EntityFramework.ObjectContextExtensions.AttachAsModified[T](ObjectSet`1 objectSet, T current, T original)
   at SchoolPortal.Web.SchoolPortalService.UpdateCld_friend_request(cld_friend_request currentcld_friend_request) in D:\J\SchoolPortal.Web\SchoolPortalService.cs:line 321
   at UpdateCld_friend_request(DomainService , Object[] )
   at System.ServiceModel.DomainServices.Server.ReflectionDomainServiceDescriptionProvider.ReflectionDomainOperationEntry.Invoke(DomainService domainService, Object[] parameters)
   at System.ServiceModel.DomainServices.Server.DomainService.InvokeDomainOperationEntry(DomainOperationEntry domainOperationEntry, Object[] parameters, ChangeSetEntry operation)
   at System.ServiceModel.DomainServices.Server.DomainService.InvokeCudOperations()
   at System.ServiceModel.DomainServices.Server.DomainService.ExecuteChangeSet()
   at System.ServiceModel.DomainServices.Server.DomainService.Submit(ChangeSet changeSet)

Upvotes: 2

Views: 1417

Answers (4)

Pranav Singh
Pranav Singh

Reputation: 20171

You are using Entity framework, seems you have modified the dataset in a way that primary key is also modified & thus EF is not able to identify which records are to be updated so this error occurs.

Refer these articles for more details & solution:

Compositional Hierarchies

http://brettsam.com/2011/03/25/ria-services-composition-with-entity-framework/

http://sklementiev.blogspot.in/2011/03/composites-in-wcf-ria-take-2.html

http://sgomez.blogspot.in/2011/03/wcf-ria-compositions.html

There is one different question on so but I think this is solution to your problem:

Update primary key value using entity framework

Upvotes: 0

prathmanu
prathmanu

Reputation: 93

Check for all the tables somewhere you miss the set the primary key and integer to Identity column

Upvotes: 0

Andy Li
Andy Li

Reputation: 189

We got this problem when one of our developer change all reference with "Copy Local" to "True".

By changing the value to "False" one by one, we found "System" is the only item we can't "Copy" to "Local".

We wish some one from Ria Service team could explain this.

Upvotes: 0

prathmanu
prathmanu

Reputation: 93

It was Just a simple solution .... Go to the references in your web project and right click System and make copy local false... It worked like charm...

Thank you Pranav Singh for your comment on this query

Upvotes: 1

Related Questions