zoukankan      html  css  js  c++  java
  • Entity Framework 连接低版本数据库

    使用EF6连接SQL2012生成的Edmx,分页时生成的查询语句使用了SQL 2012引入的新特性  OFFSET 0 ROWS FETCH NEXT 20 ROWS ONLY,结果在生产环境使用的数据库是SQL Server 2008 R2的,它不支持改特性。

    在MSDN上找到一段know Issues:

    Targeting the Correct SQL Server Version

     

    The Entity Framework targets the Transact-SQL query based on the SQL Server version that is specified in the ProviderManifestToken attribute of the Schema element in the storage model (.ssdl) file. This version might differ from the version of the actual SQL Server you are connected to. For example, if you are using SQL Server 2005, but your ProviderManifestToken attribute is set to 2008, the generated Transact-SQL query might not execute on the server. For example, a query that uses the new date time types that were introduced in SQL Server 2008 will not execute on earlier versions of the SQL Server. If you are using SQL Server 2005, but your ProviderManifestToken attribute is set to 2000, the generated Transact-SQL query might be less optimized, or you might get an exception that says that the query is not supported. For more information, see the CROSS and OUTER APPLY Operators section, earlier in this topic.

    Certain database behaviors depend on the compatibility level set to the database. If your ProviderManifestToken attribute is set to 2005 and your SQL Server version is 2005, but the compatibility level of a database is set to "80" (SQL Server 2000), the generated Transact-SQL will be targeting SQL Server 2005, but might not execute as expected due to the compatibility level setting. For example, you might lose ordering information if a column name in the ORDER BY list matches a column name in the selector.

    ProviderManifestToken 从2012设置为2008之后,果断成了。

  • 相关阅读:
    javaEE中的字符编码问题
    java泛型中<?>和<T>有什么区别?
    list去重,String[]去重,String[]去空,StringBuffer去重,并且以','隔开,list拆分
    字符串转驼峰
    动态生成16位不重复随机数、随机创建2位ID
    POI不同浏览器导出名称处理
    图片转流
    RSA加密解密
    idea 使用在java 包下的ftl、xml 文件编译问题
    深入理解SQL的四种连接-左外连接、右外连接、内连接、全连接
  • 原文地址:https://www.cnblogs.com/JasonLiao/p/EF_ProviderManifestToken.html
Copyright © 2011-2022 走看看