Issue: After upgrading Silverlight application from Silverlight 4 to Silverlight 5, updating data via RIA service throws Error "The property '<xxxxxx - a key property name>_id' is part of the object's key information and cannot be modified."

Example Call Stack:

Message="The property 'KeyName_id' is part of the object's key information and cannot be modified. "
Source=System.Data.Entity
   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 xxxxxx. ... xxx_DomainServiceClass.Update...
   at Updatexxx...
   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)

Root Cause: “[RoundtripOriginal()]” is not generated by RIA Service in the auto-generated code file: <SLProjectName>.Web.g.cs.

Troubleshooting tips: This type of error happened only after Silverlight version upgrade usually is caused by referenced assemblies mismatch. The best way is to isolate the issue down by removing references one by one and related code.
In this particular case, the issue is caused by a specific version System.Windows.dll (5.0.61118.0) referenced locally in the Web Project that hosts the RIA Service .

Resolution: remove the System.Windows.dll reference from the RIA service web proejct and make sure it is deleted form the local bin folder. After this, RIA service generated [RoundtripOriginal()] for key properties as expected.

For Example:

 [DataMember()]
        [Editable(false, AllowInitialValue=true)]
        [Key()]
        [RoundtripOriginal()]
        public Guid ApplicationId
        {
            get
            {
                return this._applicationId;
            }
            set
            {
                if ((this._applicationId != value))
                {
                    this.OnApplicationIdChanging(value);
                    this.ValidateProperty("ApplicationId", value);
                    this._applicationId = value;
                    this.RaisePropertyChanged("ApplicationId");
                    this.OnApplicationIdChanged();
                }
            }
        }

If the mismatching System.Windows.dll reference is added back, we will see warning message in the <SLProjectName>.Web.g.cs file (a hidden file to show a hidden file in VS.net,
you will need to select the project in Solution Explorer, then click the "show all files" icon on the top).

        // The following attributes were not generated:
        //
        // - The attribute 'System.ComponentModel.DataAnnotations.RoundtripOriginalAttribute' is not visible in the client project 'YourSilverlightProjectName'. Are you missing an assembly reference?
        // [RoundtripOriginalAttribute()]
        //

This warning message will be in <SLProjectName>.Web.g.cs file for each key property.

Once the mismatch reference is removed and clean solution then rebuild solution, [RoundtripOriginal()] will be generated. After [RoundtripOriginal()] is generated for each key property in <SLProjectName>.Web.g.cs, the error "The property '<xxxxxx - a key property name>_id' is part of the object's key information and cannot be modified." with exception call stack above will be gone.