locked
'Conflicting changes to the role have been detected' when trying to save Serialized Entity object. RRS feed

  • Question

  • Hi,

     

    I have 2 entity objects "Order" and "Order_Detail" from Northwind database.

    I created Self Tracking Code Generation item and also update the default T4T to include the Serializable atrribute in order to persist the POCO entity after retrieving the data.

    I am using the disconnected architecture i.e. n-tier architecture, so for this i send the POCO objects to the client side after retrieving the data and filling the entity objects.

    On the UI client side, once the POCO object is received I save the POCO entity onto disk in order to persist it. Then once the user makes any changes i retrive the POCO object and make user update on that same entity received from BAL layer(persisted Object).

    There is one catch here. According to my design i first persist the parent object then i also persist ever child object which will be shown onto a Grid control separately. This is because the grid control doesn't know about the parent object and will return the updated Entity object to be attached to the parent.

     

    Here's the Code

    public static Serialized Serialized { get; set; }
        static void Main(string[] args)
        {
          TestBC testBC = new TestBC();
          Serialized = new Serialized();
    
          var order = testBC.GetOrder(10257);
          Serialized["order"] = order;
          Serialized["order_Details"] = order.Order_Details;
    
          Order_Detail orderDetail = new Order_Detail();
          orderDetail.ProductID = 10249;
          orderDetail.UnitPrice = 7;
    
          var order1 = (Order)Serialized["order"];
          order1.EmployeeID = 5;
          var orderDetails = (TrackableCollection<Order_Detail>)Serialized["order_Details"];
          orderDetails.Add(orderDetail);
    
          order1.Order_Details.Clear();
    
          foreach (var detail in orderDetails)
          {
            order1.Order_Details.Add(detail);
          }
    
          testBC.UpdateOrder(order1);
        }
    

    But when i try to save the updated record to database it throws with following error:

    Conflicting changes to the role 'Orders' of the relationship 'NorthwindModel.FK_Order_Details_Orders' have been detected.

     

    Can tell me what should i be doing in order to resolve this error.

     

    Thanks,

    Huzefa Katwarawala


    Developer in .Net
    Friday, November 19, 2010 5:24 PM

All replies

  • Hello Huzefa,

    Could I ask if you debug the code line by line, where the exception occurs? Would you  please post the call stack here? That would be helpful to diagnose the issue.

    Thanks a lot!


    Best Regards,
    Roahn Luo
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com
    Wednesday, November 24, 2010 12:00 PM