none
Entity Framework Referential integrity constraint violation RRS feed

  • Question

  • When i try to insert a value in a table which is having a navigation proeprty and i want to insert that value as well, i got this error:

    Referential integrity constraint violation. A Dependent Role has multiple principals with different values.

    Employee employee=new Employee() 
    { 
    Name="abc", 
    Age=55 
    }; 
    employee.Add(customers);   
    context.Add(employee); 
    context.Save(); 
    //Here comes the error 
    

    Kindly help

    Thanks


    Manvinder Singh MCA, MCTS
    Tuesday, December 20, 2011 4:40 AM

Answers

  • Hi Manvinder,

    Welcome to MSDN Forum!

    Based on the issue, I think the assossiation between employee and customers is one to many, so one customer can only belongs to one empolyee. Please double check whether your 'customers' has already added to another employee.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Wednesday, December 21, 2011 2:14 AM
    Moderator