正在使用的SQL Server版本不支持datetime类型datetime2? [英] The version of SQL Server in use does not support datatype datetime2?

查看:199
本文介绍了正在使用的SQL Server版本不支持datetime类型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, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)

   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.Common.DbCommand.ExecuteReader(CommandBehavior behavior)

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



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

I have a website using Entity Framework. A few months ago I added a new table, and added some columns to existing tables; everything worked fine.

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

Today I updated the mapping of the EDMX so the new table and the new column can be used, and added WebMethods to my services.asmx file. Since then I cannot run my site because I have that error that I cannot understand. Please explain it to me if you understand, and tell me where is my mistake.

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

I have not used datetime2 anywhere. There is no such datatype in my new table, nor in the columns that I added to existing tables.

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

The version of SQL on my PC is SQL2008 R2, on the server i have SQL2008. I do not have the option to upgrade the server to R2.

推荐答案

除了@Mithrandir应答还可以验证您的数据库正在运行在兼容级别设置为100(SQL 2008)。

In addition to @Mithrandir answer validate that your database is running in compatibility level set to 100 (SQL 2008).

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

You don't have to use DATETIME2 in your database to get this error. This error happens usually once you add required (NOT NULL) DATETIME column to existing table and you don't set the value prior to saving the entity to database. In such case .NET will send default value which is 1.1.0001 and this value doesn't fit into DATETIME range. This (or something similar) will be source of your problem.

这篇关于正在使用的SQL Server版本不支持datetime类型datetime2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆