您的位置:首页 > 其它

EF 多线程插入 Insert into DbContext Multithreading

2015-08-11 09:17 253 查看
当通过task 插入多条数据时报错。

DBcontext 不是线程安全的, 如果是WebAPI 为每个请求创建DbContext

部分解释:

http://stackoverflow.com/questions/28106267/insert-into-dbcontext-multithreading#

DbContext
isn't thread-safe.

One context and many threads - it is a bad practice. It is best to create the context for each thread. I could recommend to you reconsider your algorithm and reate the context for each thread
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: