EF--model is being created异常

使用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最新版,最后函数使用同步就好了,暂时还没有弄明白这个问题到底如何解决

转载于:https://www.cnblogs.com/weloveshare/p/5825013.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值