Entity Framework: The version of SQL Server in use does not support datatype ‘datetime2′

Chi tiết tại đây

I development against a 2008 copy of SQL Server, which normally isn’t a problem, until….. I pushed out my latest code to the production system, which runs SQL 2005, and started smoke testing the system. As soon as I tried to write a record, i got the data type exception. Its painfully in the innerexception.

So, I think to myself, I am not doing anything amazing here. I am just trying to use the Entity Framework to write simple data. Well, apparently there is a tag in the store model saying what version of SQL you are targeting. Is there an easy property window for this? Nope. Open the XML.

If you change the 2008 out the server version you are targeting. 2005 or 2000 if your old, and voila. Up and running. I guess I need to upgrade the production servers to 2008. What a pain.

Right Click your EDMX file and open with XML Editor. Change ProviderManifestToken=2008 to ProviderManifestToken=2005

Then change the following:

<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
 <!-- EF Runtime content -->
 <edmx:Runtime>
 <!-- SSDL content -->
 <edmx:StorageModels>
 <Schema Namespace="MyDataModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005"
       xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator"
       xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">
 <EntityContainer Name="MyDBModelStoreContainer">
Bb399292.note(en-us,VS.100).gif
Note: Versions of CSDL are differentiated by XML namespaces. The http://schemas.microsoft.com/ado/2008/09/edm namespace is for conceptual models in applications that target the .NET Framework 4. The http://schemas.microsoft.com/ado/2006/04/edm namespace is for conceptual models in applications that target the .NET Framework 3.5 SP1. For information about other CSDL versions and their uses, see ADO.NET Data Services.

Thêm: http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/18828257-8a08-4005-9a6e-60741612fa96/

Trả lời

Mời bạn điền thông tin vào ô dưới đây hoặc kích vào một biểu tượng để đăng nhập:

WordPress.com Logo

Bạn đang bình luận bằng tài khoản WordPress.com Đăng xuất /  Thay đổi )

Google photo

Bạn đang bình luận bằng tài khoản Google Đăng xuất /  Thay đổi )

Twitter picture

Bạn đang bình luận bằng tài khoản Twitter Đăng xuất /  Thay đổi )

Facebook photo

Bạn đang bình luận bằng tài khoản Facebook Đăng xuất /  Thay đổi )

Connecting to %s

%d bloggers like this: