Entity Framework Error: The SQL Server version in use does not support the datatype 'datetime2'.

asp.net c# entity-framework


In an ASP.NET 4.0 Web Form, I'm using the Entity Framework 4.0.

On the test server, everything is in order. However, same mistake is recorded by my Elmah when I reach the production server.

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

I quickly looked into this and discovered thatdatetime2 aka datetime2(7) the issue and environmentProviderManifestToken="2005" will find a solution.

This is my issue. My Production Server has SQL Server Express 2008, whereas my Development Server has Data Warehouse 2008 R2. So it doesn't seem appropriate to change the manifest to 2005.

My inquiries are

  1. Will it set?ProviderManifestToken="2005" work?
  2. Why did Entity Framework produce this?datetime2 if I haven't used it in any of the tables at all?
  3. Is there a better solution to this?
7/1/2011 10:57:38 AM

Accepted Answer

I have yet to come across a solution. Therefore, if you're using SQL Server Express 2008, please right-click on your edmx file, open it in an XML (Text) Editor, and setProviderManifestToken="2005" .

Not that nice of a sound. But for now, it is all I have.

7/5/2011 7:43:31 AM

Popular Answer

The solution provided in this blog article, The current version of SQL Server does not support the datetime2 datatype., seems to work for me.

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.) Here’s how the line should look against SQL Server 2005:

<Schema Namespace="OfficeBookDBModel.Store"
    Alias="Self" Provider="System.Data.SqlClient"

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow