实体框架:生成的SQL - 无法找到数据类型DATETIME2 [英] Entity Framework: Generated SQL - cannot find data type datetime2

查看:686
本文介绍了实体框架:生成的SQL - 无法找到数据类型DATETIME2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我们迁移开发SQL Server以2008年

So we migrated dev sql server to 2008.

我们的UAT的SQL Server仍然是2005年。

Our UAT sql server is still 2005.

我不得不重新生成我的实体框架模型,一些其他的原因,并在部署我的工作UAT我注意到这个错误:

i had to regenerate my entity framework model for some other reasons, and upon deploying my work to UAT i noticed this error:

无法找到数据类型DATETIME2

我分析的数据库,并注意到实体框架生成的输入参数作为DATETIME2!

I profiled the database, and noticed that Entity Framework generated the input parameter as datetime2!

N'@p__linq__0 datetime2(7)',@p__linq__0='9999-12-31 00:00:00'

这执行罚款,开发,因为DATETIME2是一种存在。但失败时部署到环境与2005年

this executes fine in dev, because datetime2 is a type there. but fails when deployed to environment with 2005.

这是某种已知类型的?为什么实体框架不使用常规的日期时间,以及我怎样才能让它在跨环境相适应?

Is this some sort of known type? Why is entity framework not using regular datetime, and how can i make it cross environment compatible?

也许这并不是2008年的升级涉及..但它是不是一个问题,在升级之前,这code并没有改变。

perhaps this is not 2008 upgrade related.. but it wasn't an issue before the upgrade and this code has not changed.

推荐答案

看看<一href="http://connect.microsoft.com/VisualStudio/feedback/details/345018/entity-framework-uses-incompatible-types-e-g-datetime2-when-deployed-to-systems-with-older-sql-server-versions-even-when-source-database-had-compatibility-level-set-correctly"相对=nofollow>在MS连接这个错误 - 的解决方法似乎提供一个非常简单的修复

Take a look at this 'bug' on MS Connect - the workarounds seem to supply a fairly straightforward fix.

此外,还介绍<一href="http://stackoverflow.com/questions/3350066/linq-to-entities-produces-query-containing-datetime2-on-sql-2005-ex$p$pss">here.

这篇关于实体框架:生成的SQL - 无法找到数据类型DATETIME2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆