错误信息

1.VS实体类里面的字段

2数据库里面的字段

猜测是因为字段数不匹配导致的

3删除多余字段

5.结果

错误信息贴上:

-------------------------Log_Header-------------------------
2015-06-06 18:54:05,942 [6] ERROR log - System.Data.Entity.Infrastructure.DbUpdateException: 更新条目时出错。有关详细信息,请参阅内部异常。 ---> System.Data.Entity.Core.UpdateException: 更新条目时出错。有关详细信息,请参阅内部异常。 ---> System.Data.SqlClient.SqlException: 不能将值 NULL 插入列 'LoTVersion',表 'LoTBlog.dbo.BaseInfo';列不允许有 Null 值。INSERT 失败。
语句已终止。
在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
在 System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
在 System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
在 System.Data.SqlClient.SqlDataReader.get_MetaData()
在 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
在 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
在 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
在 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
在 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
在 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.<Reader>b__c(DbCommand t, DbCommandInterceptionContext`1 c)
在 System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
在 System.Data.Entity.Infrastructure.Interception.DbCommandDispatcher.Reader(DbCommand command, DbCommandInterceptionContext interceptionContext)
在 System.Data.Entity.Internal.InterceptableDbCommand.ExecuteDbDataReader(CommandBehavior behavior)
在 System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)
在 System.Data.Entity.Core.Mapping.Update.Internal.DynamicUpdateCommand.Execute(Dictionary`2 identifierValues, List`1 generatedValues)
在 System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
--- 内部异常堆栈跟踪的结尾 ---
在 System.Data.Entity.Core.Mapping.Update.Internal.UpdateTranslator.Update()
在 System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.<Update>b__2(UpdateTranslator ut)
在 System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update[T](T noChangesResult, Func`2 updateFunction)
在 System.Data.Entity.Core.EntityClient.Internal.EntityAdapter.Update()
在 System.Data.Entity.Core.Objects.ObjectContext.<SaveChangesToStore>b__d()
在 System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
在 System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
在 System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClassb.<SaveChangesInternal>b__8()
在 System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
在 System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
在 System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options)
在 System.Data.Entity.Internal.InternalContext.SaveChanges()
--- 内部异常堆栈跟踪的结尾 ---
在 System.Data.Entity.Internal.InternalContext.SaveChanges()
在 System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
在 System.Data.Entity.DbContext.SaveChanges()
在 LoT.Dal.BaseDal`1.AddModel(T model) 位置 e:\Works\Net\LoTBlog\001-Source\LoTCode\LoTBlog\LoT.Dal\BaseDal.cs:行号 26
在 LoT.Service.BaseService`1.AddModel(T model) 位置 e:\Works\Net\LoTBlog\001-Source\LoTCode\LoTBlog\LoT.Service\BaseService.cs:行号 33
在 LoTBlog.Back.Controllers.BaseInfoController.Update(BaseInfo baseInfo) 位置 e:\Works\Net\LoTBlog\001-Source\LoTCode\LoTBlog\LoTBlog.Back\Controllers\BaseInfoController.cs:行号 164
在 lambda_method(Closure , ControllerBase , Object[] )
在 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
在 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
在 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41()
在 System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
在 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33()
在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49()
在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass37.<BeginInvokeActionMethodWithFilters>b__36(IAsyncResult asyncResult)
在 System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
在 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<>c__DisplayClass2a.<BeginInvokeAction>b__20()
在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult)

转载于:https://www.cnblogs.com/dunitian/p/4557162.html

EF-DbUpdateException--实体类和数据库列不对应的解决方案相关推荐

  1. Springboot根据实体类生成数据库表

    springboot数据库(一)-springboot-JPA JPA:springboot -jpa:数据库的一系列的定义数据持久化的标准的体系 学习的目的是: 利用springboot实现对数据库 ...

  2. 根据实体类生成数据库表

    参考文档地址:通过实体类生成数据库表_weixin_44571808的博客-CSDN博客_java实体类生成数据库表 注意springboot版本号需要比较低(没有详细测试2.6不行,2.1.11可以 ...

  3. MyBatis入门实例-包括实体类与数据库字段对应CLOB字段处理

    1.我的开发环境是 jdk1.7+ecplise+oracle 11g 用到的jar包:mybatis-3.1.1.jar ojdbc6.jar 2.项目整体结构 3.首先配置conf.xml文件 [ ...

  4. java获取spring注解的实体_Spring 注解实体类中非数据库字段属性

    今天要给一个实体类添加一个List集合属性! private List childList = new ArrayList(); 写完后get/set方法一写,启动就报错: org.hibernate ...

  5. MyBatis由浅入深学习总结之二:MyBatis解决Java实体类和数据库表字段不一致方法总结

    在此,首先说明一点任何持久性框架都需要解决一个问题,那就是Java实体类的字段一般来说基本上会与数据库表中字段不一致,那么它们是如何解决的呢?咱们以Hibernate和SpringJDBC为例说明一下 ...

  6. mybatisPlus 实体类与数据库表映射关系

    使用mybatisPlus时,会确定实体类和数据的映射关系 具体的映射方法有两种: 1.默认:采用驼峰映射规则,例如MyUserTable 对应的数据库表为 my_user_table ;  TEMy ...

  7. 实体类与数据库字段类型

    实体类 /*实体类*/ @Column(precision = 12, scale = 3) private BigDecimal rate; //数据库字段类型 rate decimal(12,3) ...

  8. SpringBoot中使用Mybatis逆向工程(实体类含数据库注释)

    Mybatis逆向工程:根据创建好的数据库表,生成对应的实体类.DAO.映射文件 文章目录 开发环境 1.新建SpringBoot应用 2.添加逆向工程插件依赖 3.执行逆向生成 开发环境 开发工具: ...

  9. mysql 不能用dbcontext_使用DbContext实体类访问数据库

    首先要把 EFCodeFirst类库工程里,添加EntityFramework的引用. /// /// FileInfo:实体类名要和数据表名的名称一样. /// [Serializable] pub ...

最新文章

  1. 机器学习(16)ROC曲线与AUC指标(癌症分类的模型检测--AUC指标)
  2. 无边框窗体的移动(winform/wpf)
  3. java架构师学习笔记
  4. 5.8.1 创建类型实例
  5. 每次ubuntu12.04重启后,/etc/resolv.conf被重写为空或127.0.0.1
  6. radare2 常用操作总结
  7. MapReduce源码刨析
  8. 怎么取消打开文件的安全警告?
  9. poj 1743 二分答案+后缀数组 求不重叠的最长重复子串
  10. SBUS协议转换芯片,SBUS转UART,sbus转rs232,sbus解码IC,zr003
  11. Python 标准库和第三方库的安装位置、Python 第三方库安装的各种问题及解决
  12. 企业开发基础设施--序
  13. ajax调用webService
  14. # 研究杂感 × VOSviewer(第六辑)
  15. HIMSS博览会首登中国 建言医卫IT新发展
  16. python 谷歌翻译
  17. 细数那些年经典有深度的电影
  18. Ubuntu怎么切换为中文版
  19. js分享到微信朋友圈、QQ空间、QQ好友、新浪微博、腾讯微博、豆瓣、人人......
  20. 1. PYNQ在ZCU102上的移植【PYNQ】

热门文章

  1. python 原理 pdf_《深入浅出深度学习:原理剖析与Python实践》.pdf
  2. EasyUI -- Layout(布局)
  3. sql服务器显示error,SQL server 2008 登陆服务器时提示错误233
  4. espresso java_java – Espresso单击菜单项
  5. java快捷键设置sop,今日工作总结|sop整理
  6. unity3d 自动变化大小_自动做游戏(1),自动生成人物侧面图
  7. mysql 不认的字符串_mysql 判断字符串是否为其他字符串的子集
  8. java 打包工具_Java打包Windows安装程序
  9. python药店销售数据分析_解析医院药店销售数据,看看Python数据分析结果有什么惊人的发现|python基础教程|python入门|python教程...
  10. springmvc连接mysql_挺详细的spring+springmvc+mybatis配置整合|含源代码