The Version of SQL Server in Use Does Not Support Datatype Datetime2

The version of SQL Server in use does not support datatype datetime2?

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

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 2012 : The version of SQL Server in use does not support datatype 'datetime2'

What is the compatibility level of that database you're running against?

Check using

SELECT compatibility_level 
FROM sys.databases
WHERE name = 'YourDatabaseNameHere'

DATETIME2 was introduced in SQL Server 2008 - so if that level is below 100 (which is SQL Server 2008), then the DATETIME2 data type isn't available yet.

If the database was upgraded from a SQL Server 2005 instance, most likely, it's compatibility level is still at 90 (SQL Server 2005) and thus the DATETIME2 datatype isn't available yet.

You can upgrade your database compatibility level to more recent values using:

ALTER DATABASE YourDatabaseNameHere
SET COMPATIBILITY_LEVEL = 100;

where level = 100 is SQL Server 2008 / 2008 R2, and level = 110 is SQL Server 2012

SQL server version error (datetime2)

if you are using Entity framework and sql server then actually issue is in Entity framework.

you have to make some changes in entity framework.

check below link would be helpful.

Entity Framework Error - The version of SQL Server in use does not support datatype 'datetime2'

Error ASP.NET Core EF Core and SQL Server 2005: The version of SQL Server in use does not support datatype 'datetime2'

EF Core does not support SQL Server 2005, but 2012 and forward

https://learn.microsoft.com/en-us/ef/core/providers/sql-server/

System.ArgumentException: The version of SQL Server in use does not support datatype 'datetime2

It turns out that Entity Framework 4 somehow got the idea to use SQL Server 2008. The fix was to edit the .edmx file in an XML editor and set the ProviderManifestToken="2005" instead of 2008. (You need to rebuild.)

Entity Framework Error - The version of SQL Server in use does not support datatype 'datetime2'

I dont see any workaround till date. So if you are using SQL Server 2008 Express, please right click on your edmx, open it with XML (Text) Editor and set ProviderManifestToken="2005".

Doesn't sound that good. But its all I have got as of now.

Does SQL Server 2005 support datetime2

Apparently it does not. Here are the supported data types.

EDIT:

According to the following sources datetime2 was introduced in SQL Server 2008.

http://blogs.msdn.com/b/manisblog/archive/2007/08/28/sql-server-2008-enhancements-in-date-and-time-data-types.aspx

https://web.archive.org/web/20211020150018/https://www.4guysfromrolla.com/articles/101508-1.aspx

The SQL version used is not compatible with data type 'datetime2'

DateTime2 is only available on SqlServer 2008 or later

DATETIME2 is introduced in SQL Server 2008

You can change what you want on your "client" application, if the server does not supported it will not work.



Related Topics



Leave a reply



Submit