locked
Reference properties cannot be set to deleted or discarded entities. Parameter name: value RRS feed

  • Question

  • Hi!

    I have a problem with audit trial. Inserting and Updating works fine but when Deleting i get error message.

    I have found that allot of us used same code, got same error but no one found the solutions for it...

    This is my code:

    partial void HandoverSheetAogDesks_Deleted(HandoverSheetAogDesk entity)
            {
                var change = entity.AuditTrials.AddNew();
                change.ChangeType = "Deleted";
    
                change.Updated = DateTime.Now;
                change.ChangedBy = this.Application.User.FullName;
    
                var oldvals = "Deleted Values:";
    
                foreach (var prop in entity.Details.Properties.All().OfType<Microsoft.LightSwitch.Details.IEntityStorageProperty>())
                {
                    if (prop.Name != "Id")
                    {
                        oldvals += string.Format("{0}{1}: {2}", Environment.NewLine, prop.Name, prop.Value);
                    }
                }
    
                change.OriginalValues = oldvals;
            }

    Error message is: Reference properties cannot be set to deleted or discarded entities. Parameter name: value

    Thank you!

    Monday, November 11, 2013 2:39 PM