Entity framework 4 实体框架-如何知道在保存期间哪个属性引发了异常?

Entity framework 4 实体框架-如何知道在保存期间哪个属性引发了异常?,entity-framework-4,Entity Framework 4,我有一堆SQL中有数百个字段的实体,其中几十个是不可空的。我希望创建实体,保存并查看它抱怨的字段,这样我就可以轻松地包含它(使用单元测试非常快速/容易),但是我从EF返回的信息没有显示哪个字段/属性导致了错误?为什么会这样?我甚至尝试/捕获了输出异常,但没有关于该问题的其他信息:-( 酷,像这样的东西怎么样:CreateDate 谢谢…您可以使用DbContext.GetValidationErrors()方法检索验证规则中断信息 System.Data.UpdateException : An

我有一堆SQL中有数百个字段的实体,其中几十个是不可空的。我希望创建实体,保存并查看它抱怨的字段,这样我就可以轻松地包含它(使用单元测试非常快速/容易),但是我从EF返回的信息没有显示哪个字段/属性导致了错误?为什么会这样?我甚至尝试/捕获了输出异常,但没有关于该问题的其他信息:-(

酷,像这样的东西怎么样:CreateDate


谢谢…

您可以使用
DbContext.GetValidationErrors()
方法检索验证规则中断信息

System.Data.UpdateException : An error occurred while updating the entries. See the inner exception for details.
  ----> System.Data.SqlTypes.SqlTypeException : SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
   at PaymentDomain.IntegrationTests.EFTestSetup.Test() in EFTestSetup.cs: line 40
--SqlTypeException
   at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc, Boolean sync, TaskCompletionSource`1 completion, Int32 startRpc, Int32 startParam)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, ref Task task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, ref Task task, Boolean asyncWrite)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
   at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)