2

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)
abatishchev
  • 98,240
  • 88
  • 296
  • 433
prathmanu
  • 93
  • 9

4 Answers4

1

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

prathmanu
  • 93
  • 9
0

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

Community
  • 1
  • 1
Pranav Singh
  • 17,079
  • 30
  • 77
  • 104
  • My DB table is a simple one with a primary key and the entity also created same way but on update its giving me this error... – prathmanu Jun 16 '14 at 05:25
0

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.

Andy Li
  • 189
  • 6
0

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

prathmanu
  • 93
  • 9