I have the following classes with many-to-many relation:
Now, I would like to add existing invoice to the customer:
When try to run the snippet written above, the following exception is thrown:
Cannot insert duplicate key into ‘dbo.CustomerInvoices’….
What is the problem?
After spending a couple of minutes on searching solution, it turned out that remedy is very simple:
Yes, virtual word was the key. Without it, EF is not able to track changes. But why such an error was thrown? Do not know, maybe you guys?