You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You execute a method from the Entity Framework Extensions library, and the following error is thrown:
12
+
13
+
- Type: DbBulkOperationConcurrencyException
14
+
15
+
{% include template-exception.html message='A concurrency exception has occured. Entities may have been modified or deleted since entities were loaded.' %}
16
+
17
+
## Solution
18
+
19
+
### Cause
20
+
21
+
Another thread have already performed the operation.
22
+
23
+
### Fix
24
+
25
+
There is three possible resolution:
26
+
27
+
- Database Win
28
+
- Client Win
29
+
- Custom Resolution
30
+
31
+
#### Database Win
32
+
{% highlight csharp %}
33
+
public void BulkUpdate_DatabaseWins<T>(CurrentContext ctx, List<T> list) where T : class
34
+
{
35
+
try
36
+
{
37
+
ctx.BulkUpdate(list);
38
+
}
39
+
catch (DbBulkOperationConcurrencyException ex)
40
+
{
41
+
// DO nothing (or log), keep database values!
42
+
}
43
+
}
44
+
{% endhighlight %}
45
+
46
+
#### Client Win
47
+
{% highlight csharp %}
48
+
public void BulkUpdate_StoreWins<T>(CurrentContext ctx, List<T> list) where T : class
0 commit comments