Does Entity Framework support Multi-Threading?

前端 未结 1 1633
逝去的感伤
逝去的感伤 2021-01-14 07:42

I am writing a C# .NET4.5 Console application targeting the Entity Framework 6.1.3. I am using the Unit Of Work paradigm as follows:

public class UnitOfWork          


        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-14 08:24

    The documentation for DataContext states:

    Any instance members are not guaranteed to be thread safe.

    And that's what I've experienced too. I've tried to do what you're doing and I've seen bizarre errors that backup the idea that it is not thread safe.

    You will have to create a new DataContext instance in each thread.

    0 讨论(0)
提交回复
热议问题