bug1:
类型系统的一个例外。InvalidOperationException异常”发生在EntityFramework.dll而不是在用户代码处理
附加信息:上下文时不能被创造使用模型。可能会引发此异常,
如果上下文在OnModelCreating方法或用如果相同的上下文实例访问的并发多线程。
注意,实例成员DbContext和相关的类不保证是线程安全的
问题原因:
两个页面同时访问会出现此异常
@*@RenderPage("~/Views/Home/Index2.cshtml") @RenderPage("~/Views/Home/Index4.cshtml")*@
在EntityFramework.dll中出现了“Syt.NoStuttExtExpCype”类型的异常,但未在用户代码中处理。
附加信息:无法检查模型兼容性,因为没有使用代码第一模式创建DbCurror实例。
从ObjeCype或使用EDMX文件创建的DbCurrar实例不能
bug 2:
An exception of type 'System.NotSupportedException' occurred in EntityFramework.dll but was not handled in user code
Additional information: Model compatibility cannot be checked because the DbContext instance was not created using Code
First patterns. DbContext instances created from an ObjectContext or using an EDMX file cannot be
在EntityFramework.dll中出现了“Syt.NoStuttExtExpCype”类型的异常,但未在用户代码中处理。
附加信息:无法检查模型兼容性,因为没有使用代码第一模式创建DbCurror实例。
从ObjeCype或使用EDMX文件创建的DbCurrar实例不能
解决:把原来的edmx文件删除,先创建好实体类的cs文件,还有创建好数据库表,已经主键等,在通过ef上下文
进行关联。就解决了不是使用代码第一模式创建实例的问题
An exception of type 'System.Data.Entity.Infrastructure.DbUpdateException'
occurred in EntityFramework.dll but was not handled in user code
Additional information: An error occurred while updating the entries.
See the inner exception for details.
解决:主要是表没有设置主键,特别是自增长,以至于插入和删除有问题
An exception of type 'System.Data.Entity.Infrastructure.DbUpdateException' occurred in EntityFramework.dll but was not handled in user code
Additional information: Unable to update the EntitySet 'Ptype' because it has a DefiningQuery
and no <InsertFunction> element exists in the <ModificationFunctionMapping> element to support the current operation.
只有查询功能,没有更新功能
解决:设置主键