使用EF的时候出现了下面的异常,我使用了TASK和saveChangeAsync()异步
The context cannot be used while the model is being created. This exception may be thrown if the context is used inside the OnModelCreating method or if the same context instance is accessed by multiple threads concurrently. Note that instance members of DbContext and related classes are not guaranteed to be thread safe.
微软论坛的解释
I have test your code, it can work well in my compter.
I have experienced this issue in the past and usually it was due not using the latest version + referencing issue.
Another reason for this error can be that while you create the context the first time and therefore cause the model to be created you create another context on a separate thread. You will have to wait for other context instances to be created after the model creation has completed.
但是我感觉应该不是EF版本的问题,我的是EF6.1.3最新版,最后函数使用同步就好了,暂时还没有弄明白这个问题到底如何解决