简体   繁体   English

EF4和SQL Server 2000

[英]EF4 & SQL Server 2000

I've developed my website using EF4 and SQL Server 2005, but when moving to the staging site it turns out that they use SQL Server 2000. 我已经使用EF4和SQL Server 2005开发了我的网站,但是当移到暂存站点时,事实证明它们使用SQL Server 2000。

Now I'm getting this error, which I believe is related to SQL Server 2000: 现在,我收到此错误,我认为它与SQL Server 2000有关:

Incorrect syntax near '('. 'row_number' is not a recognized function name.

Is there a way of fixing this? 有办法解决这个问题吗?

Thanks 谢谢

I came across the exact same problem and as per the comments/responses on StackOverflow I had almost given up and flicked it to client to upgrade their database to > 2000 version. 我遇到了完全相同的问题,并且根据对StackOverflow的评论/响应,我几乎放弃了,并将其甩给客户端,以将其数据库升级到> 2000版本。 Unfortunately that wasn't possible for them due to many other issues. 不幸的是,由于许多其他问题,这对他们来说是不可能的。 I had to go around googling for a solution and from somewhere I found a work-around. 我不得不四处寻找解决方案,并从某个地方找到了解决方法。

This is what I did. 这就是我所做的。

  • Right clicked the ModelName.EDMX file -> Open With 右键单击ModelName.EDMX文件->打开方式
  • Selected XML (Text) Editor 选定的XML(文本)编辑器
  • Found ProviderManifestToken="2005" and replaced it with ProviderManifestToken="2000" 找到ProviderManifestToken =“ 2005”并将其替换为ProviderManifestToken =“ 2000”
  • Published the changes and voila! 发布了更改,瞧!

Now the reason I'm saying it's a work-around (not a solution) is because 现在,我说这是一种解决方法(不是解决方案)的原因是

  1. If you update your model from database again and your development machine database is >= 2000 (which is likely to be a case as SQL 2000 connection is not supported at all by MS according to this article ) this value in the XML will change automatically 如果您再次从数据库中更新模型,并且开发机器的数据库> = 2000(可能是这种情况,因为根据本文 ,MS完全不支持SQL 2000连接),XML中的该值将自动更改

  2. Also, the queries generated by EF after this change have worked in my situation but I cannot guarantee that all the queries ever generated by your application would work without any problems 另外,在这种情况下,EF生成的查询在我的情况下仍然有效,但我不能保证您的应用程序曾经生成的所有查询都可以正常工作

Row_Number() returns the sequential number for a each row returned. Row_Number()返回所返回的每一行的序号。 Are you calling Row_number(), or is the entity framework? 您是在调用Row_number()还是实体框架?

Either way, you may be able to write a user-defined function that re-implements ROW_NUMBER. 无论哪种方式,您都可以编写一个用户定义的函数来重新实现ROW_NUMBER。 Stackoverflow post on this here: ROW_NUMBER Alternative for SQL Server 2000 关于此的Stackoverflow帖子在这里: ROW_NUMBER SQL Server 2000的替代方法

Not sure this is going to do any good in the long run; 不确定这从长远来看是否会带来好处。 you're likely to find that you get around this problem only to encounter the next reason that EF doesn't work on SQL 2000. But, it might be worth the few minutes to try. 您可能会发现您只是在遇到EF无法在SQL 2000上工作的另一个原因时才解决此问题。但是,值得花几分钟的时间尝试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM