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范围。这(或类似的东西)将成为您问题的根源。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。