c# - Entity Framework: Incorrect syntax near ‘OFFSET’

2 篇文章 0 订阅

Friends,

This post explains the solution to an issue that occurs with Entity Framework used against SQL Server 2008 database. The error is –

An error occurred while executing the command definition. See the inner exception for details. —> System.Data.SqlClient.SqlException: Incorrect syntax near ‘OFFSET’.

The error occurs if you are using Entity Framework EDMX file (this is to be noted that the error occurs only with Database first and not code-first approach) in your project and are taking benefit of the Take() or Skip() functions. Also, the error occurs only when the EDMX file has been generated the designer file using SQL Server 2012 but are trying to run the code against a production SQL server using 2008 or 2008 R2.

 
 
  1. var data = db.Employees.Where(v => v.PatientID == patientID).OrderByDescending(v=>v.ID).Take(10).Skip(1).ToList();

The solution is to open the EDMX designer in a XML editor and change the value ofProviderManifestToken property from “2012” to “2008”.

Hope this small tip helps you. Cheers.

原文:http://www.niteshluharuka.com/solution-error-entity-framework-incorrect-syntax-near-offset/



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值