正在使用的SQL Server版本不支持数据类型datetime2?

前端之家收集整理的这篇文章主要介绍了正在使用的SQL Server版本不支持数据类型datetime2?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
An error occurred while executing the command definition. See the inner exception for details. bbbbInnerException:aaaa System.ArgumentException: The version of sql Server in use does not support datatype 'datetime2'.

   at System.Data.sqlClient.TdsParser.TdsExecuteRPC(_sqlRPC[] rpcArray,Int32 timeout,Boolean inSchema,sqlNotificationRequest notificationRequest,TdsParserStateObject stateObj,Boolean isCommandProc)

   at System.Data.sqlClient.sqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior,RunBehavior runBehavior,Boolean returnStream,Boolean async)

   at System.Data.sqlClient.sqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,String method,DbAsyncResult result)

   at System.Data.sqlClient.sqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,String method)

   at System.Data.sqlClient.sqlCommand.ExecuteReader(CommandBehavior behavior,String method)

   at System.Data.sqlClient.sqlCommand.ExecuteDbDataReader(CommandBehavior behavior)

   at System.Data.Common.DbCommand.ExecuteReader(CommandBehavior behavior)

   at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand,CommandBehavior behavioR

我有一个使用Entity Framework的网站。几个月前,我添加了一个新表,并在现有表中添加了一些列;一切正常。

今天我更新了EDMX的映射,以便可以使用新表和新列,并将WebMethods添加到我的services.asmx文件中。从那时起,我无法运行我的网站,因为我有一个我无法理解的错误。如果你明白了,请告诉我,并告诉我我的错误在哪里。

我没有在任何地方使用datetime2。我的新表中没有这样的数据类型,也没有添加到现有表的列中。

我的PC上的sql版本是sql2008 R2,在我有sql2008的服务器上。我没有选择将服务器升级到R2。

解决方法

除了@Mithrandir之外,还要验证您的数据库是否在兼容级别设置为100的情况下运行(sql 2008)。

您不必在数据库中使用DATETIME2来获取错误。一旦将必需(NOT NULL)DATETIME列添加到现有表并且在将实体保存到数据库之前未设置该值,通常会发生此错误。在这种情况下,.NET将发送默认值1.1.0001,该值不适合DATETIME范围。这(或类似的东西)将成为您问题的根源。

原文链接:https://www.f2er.com/mssql/84433.html

猜你在找的MsSQL相关文章