views:

973

answers:

2

Hi all,

I have realized that a smalldatetime sql server data type has been mapped to a datetime in my entity project. Fine with me. When the entity is saving changes it actually uses a datetime2 data type (which currently our production database doesn't support). Now, that's a problem.

Looking at the entity designer code i see the property is using VB's date object although the properties window displays it as a datetime.

I would rather not change the entity code as I do not want updates from the database to overwrite my changes creating a code maintenance mess.

Where did the datetime2 come from? Any ideas?

Thanks in advance for any help, Orry

A: 

What does the SSDL say the property is?

Open the EDMX file up using an XML Editor (the one in VS is pretty good)

Now look in the StorageModels element for the column in question.

The 'type' of the Property in the in the SSDL section is the type the EntityFramework thinks the database column is. I suspect it will say DateTime2. You should be able to change it back to something like DateTime.

Hope this helps

Alex

Alex James
Hi Alex,Thanks for the response.The type displayed is DateTime. The sql produced uses datetime2. Our dev db (sql 2008) supports it but our production has not been upgraded yet. It will in the very near future but we want that code on production before hand (hence, the problem).Anyway, we tried changing the manifest file to use sql server version 2005 mapping instead of 2008. So far without success.
Orry
+2  A: 

Ok folks, that fixed it.

Because the entity was updating refs from a sql 2008 database the ProviderManifestToken is set to 2008. Opening the edmx file in the xml editor and changing the value to 2005 fixed our problem.

Orry
Thank you! This was a class-a pain in the butt to find a solution for.
Craig Eddy