My entity is like that:
public class Foo
{
public int Id { get; set; }
public int Bar { get; set; }
}
Bar has a unique index.
In my code I get two Foo objects:
object 1: { Id: 1, Bar: 1}
object 2: { Id: 2, Bar: 2}
What I need to do is to swap one by other:
object 1: { Id: 1, Bar: 2}
object 2: { Id: 2, Bar: 1}
and update this in a transaction. But when I do this, I get an error similar to that:
Cannot insert duplicate key row in object 'dbo.Episode' with unique index 'IX_Id_Season_Number'. The duplicate key value is (2f649a95-0a03-e511-9751-0090f5a7af27, 3, 1).
The statement has been terminated.
How can I do that?