Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Juding by your code <code>Unit = selectedUnit</code> and <code>p.Destinations.Add(dest);</code> and the other symptoms you describe you seem to have the exact same situation. My findings below have fixed the problem for me. </p> <p>Interested also if you ended up with any duplicated entities in your database as a result of this. i was getting rows already previously saved magically turning to <code>New</code> and then becoming dupe records. Again this simple change below fixed it.</p> <hr> <p>There is a race condition i discovered that can give this error if you create an entity and immediately assign foreign key relationships to it before adding the parent entity to its entity set. </p> <p>Turns out the very act of setting the foreign key relationship actually adds the entity to its corresponding entity set - but sometimes causes a race condition, especially if your UI is loading and saving and clearing entity sets.</p> <p><strong>bad:</strong></p> <pre><code>var todo = new TODO(); todo.Status = TODOContext.Statuses.Single(x=&gt;x.Status == "Unknown"); todo.AssignedTo = TODOContext.Users.Single(x=&gt;x.UserName == "JSMITH"); TODOContext.TODOs.Add(todo); // adding entity after setting FK </code></pre> <p><strong>good:</strong></p> <pre><code>var todo = new TODO(); TODOContext.TODOs.Add(todo); // add entity before setting FK todo.Status = TODOContext.Statuses.Single(x=&gt;x.Status == "Unknown"); todo.AssignedTo = TODOContext.Users.Single(x=&gt;x.UserName == "JSMITH"); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload