user441365
user441365

Reputation: 4024

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.

Now I'm getting this error, which I believe is related to SQL Server 2000:

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

Is there a way of fixing this?

Thanks

Upvotes: 2

Views: 846

Answers (3)

Hiral Desai
Hiral Desai

Reputation: 1122

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. 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
  • Selected XML (Text) Editor
  • Found ProviderManifestToken="2005" and replaced it with 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

  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

Upvotes: 1

Lynn Crumbling
Lynn Crumbling

Reputation: 13367

Row_Number() returns the sequential number for a each row returned. Are you calling Row_number(), or is the entity framework?

Either way, you may be able to write a user-defined function that re-implements ROW_NUMBER. Stackoverflow post on this here: ROW_NUMBER Alternative for 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.

Upvotes: 0

Thomas Li
Thomas Li

Reputation: 3338

EF v4 does not support SQL Server 2000. More details here:

https://connect.microsoft.com/VisualStudio/feedback/details/499186/entity-framework-v2-doesn-t-support-sql-2000

Upvotes: 4

Related Questions