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最新版,最后函数使用同步就好了,暂时还没有弄明白这个问题到底如何解决
EF--model is being created异常的更多相关文章
- 使用EF Model First创建edmx模型,数据库有数据的情况下,如何同时更新模型和数据库
使用"EF Model First",我们可以很直观地在edmx文件中创建数据模型,并根据模型生成数据库,整个过程快速而高效.可当数据库中有了一定的数据量,同时,可能需要对模型中字 ...
- 解决问题:The context cannot be used while the model is being created
使用Entity Framework (v6.1.3)突然遇到这个问题了,之前一直好好的,怎么破? 此处省略了多次在“好”与“坏"的项目中试验的过程(苦啊),直接给出答案.答案是:没有按Db ...
- asp.net EF model中的默认值设置
在做数据库规划时,通常会规划一些系统字段,也就是由数据库本身自行指定默认值到这个字段上,创建新的“创建时间(CreateDate)”字段就会常常这样设计. 如果希望能有默认值,且让.net 程序在新增 ...
- MVC EF Model First
1 在Models下新建实体数据模型Model.edmx 2 在Model.edmx中点右键建立各个实体,增加Scalar Property 3 空白处点右键,添加关系,勾选增加外键 4 保存Mode ...
- D其他项目打电话AL工程EF Model
Based on your description and the error code, you will just need to ensure that your DataContext ...
- linq 查询的两种方法 (在EF model中实现)
众所周知:linq查询有两种方式 1.通过linq表达式查询 2.是通过linq方法查询 代码中 每一步都有注释
- EF异常探究(An entity object cannot be referenced by multiple instances of IEntityChangeTracker.)
今天在改造以前旧项目时出现了一项BUG,是由于以前不规范的EF写法所导致.异常信息如下: "An entity object cannot be referenced by multiple ...
- Entity Framework(EF的Model First方法)
EntityFramework,是Microsoft的一款ORM(Object-Relation-Mapping)框架.同其它ORM(如,NHibernate,Hibernate)一样, 一是为了使开 ...
- EF DbContext 并发执行时可能出现的问题
现在许多Web项目都使用了IOC的DI注入组件.其中对象的生命周期管理是非常重要的. 有时我们为了提高请求的响应,经常在请求线程中执行多个子线程,然而忽略了EF的DbContext的生命周期管理. D ...
随机推荐
- WP处理事件
(1).Launching事件 Launching(进入)事件是每一个第三方应用在第一次运行时都必须执行的事件,它主要负责应用程序的初始化.这个事件与Closing事件是对应的,一个运行正常的应用程序 ...
- codevs1225八数码难题(搜索·)
1225 八数码难题 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 题解 题目描述 Description Yours和zero在研究A*启 ...
- [Swift通天遁地]九、拔剑吧-(3)创建多种自定义Segment分段样式的控件
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- Visual Studio Code配置GitHub(Win7环境)
一.软件环境说明(演示环境) 1.操作系统:Windows7旗舰版(64bit) 2.Visual Studio Code版本:1.32.3 3.Git版本:2.21.0.windows.1 二.软件 ...
- Maven+Docker,发布到Registry
1.配置Pom.xml <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEnc ...
- sql 循环分割字符
DECLARE @Items VARCHAR(1000)='148' --待处理拼接字符串 --开始处理SET @Items=@Items+',' --必须追加“,”否则最后一个无法输出DECLARE ...
- xampp中localhost与DreamWaver站点设置问题
作为一个初学者,在DreamWaver中配置web服务器用于本地测试,中间碰到了好多问题,百度答案模糊不清,自己摸索出来,把自己碰到的,易错的地方做个总结. step1 : 安装xampp(安装位置记 ...
- CxImage实现9PNG
CxImage* ScaleImageBy9PNG(CxImage *pRawImage, int nDstWidth,int nDstHeight) { if(NULL == pRawImage) ...
- Apache服务器防范DoS
Apache服务器对拒绝服务攻击的防范主要通过软件Apache DoS Evasive Maneuvers Module 来实现.它是一款mod_access的替代软件,可以对抗DoS攻击.该软件可 ...
- Centos6.4 安装fail2ban防暴力破解
Centos6.4 安装fail2ban防暴力破解 一. 安装 curl -O https://codeload.github.com/fail2ban/fail2ban/tar.gz/0.9.0 m ...