Home > Net >  The.net core of a mistake
The.net core of a mistake

Time:11-19

A mistake in the.net core
An exception occurred, the system, InvalidOperationException: before the operation is complete before, in this context to start the second operation, this is usually caused by using the same DbContext examples of different threads,

O great god how to solve this problem

CodePudding user response:

Well, error said understand oh,

Only reason that we couldn't say for sure, one line of code you have no, we don't know your blog into the garden for the hole in the pit series
1. Global static?
2.10 years ago warehouse??
3. The recent ABP
4. This two days services. AddSingleton ()
5, or using dbcontext
{
Two threads?
A time??
}

CodePudding user response:

FromServices injection singleton DbContext??

CodePudding user response:

If you use the context, you use a single (accept the client request operation) thread processing, do not use "child thread" also shouldn't to invoke the callback object,

CodePudding user response:

Also, do not easily say "the.net core a mistake", is to have a basic concept of your program or. Net's fault?

CodePudding user response:

1, you use the multithreading?
2, if yes, then you use the global context? If yes, then this is not right,

Using a global context are beginners often prone to error

CodePudding user response:

Microsoft's official solution, although a little silly, but better than nothing:

Handling Concurrency Conflicts - EF Core | Microsoft Docs
https://docs.microsoft.com/en-us/ef/core/saving/concurrency