user2161690
user2161690

Reputation: 1

How to set ProviderManifestToken for Entity Framework using Code First?

We use EF 4.1 and code first. While our production databases are SQL Server 2005, some of our developers have SQL Server 2008 locally. Our TFS Build server also is 2008. When running unit tests locally and on the build server we run into issues because of the differences between datetime and datetime2. Even though the column on the database is "datetime", using SQL Profiler we can see that EF treats the column as "datetime2".

I saw articles mentioning that we should set ProviderManifestToken in our EDMX file to 2005 to solve this problem but we're using EF code first. Is there not a way so solve this using code first?

Upvotes: 0

Views: 2152

Answers (2)

Selway
Selway

Reputation: 68

see this

Just use datetime instead of datetime2. It works in my project.

Upvotes: 0

Pawel
Pawel

Reputation: 31610

For EF5 Code First it's a bit more than just changing a string in the xml. Take a look at this blog post. It contains an example of setting the provider manifest token explicitly. In EF6 you can set just configure a resolver that returns provider manifest token.

Upvotes: 1

Related Questions