实体框架6支持SQL Server 2000? [英] Entity Framework 6 supports SQL Server 2000?

查看:152
本文介绍了实体框架6支持SQL Server 2000?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道SQL Server 2000是否支持EF 6 for Code First?在官方网站上,我没有发现任何关于哪些SQL Server版本在EF 6中支持。在某些博客中,我发现不支持SQL Server 2000,但是这些博客不是官方来源。看看EF 6的源代码似乎是支持的我已经发现了一些代码与SQL Server 2000注意事项。



例如:



SqlVersion 是一个包含SQL Server版本枚举的类,SQL Server 2000在此枚举中。



https://entityframework.codeplex.com /SourceControl/latest#src/EntityFramework.SqlServer/SqlVersion.cs

  //< summary> 
//这个枚举描述了当前的SQL Server版本。
//< / summary>
内部枚举SqlVersion
{
//< summary>
// SQL Server 8(2000)。
//< / summary>
Sql8 = 80,

//< summary>
// SQL Server 9(2005)。
//< / summary>
Sql9 = 90,
.....

TopClause 是生成select TOP 子句的类,在此类中的方法 WriteSql ,为SQL Server 2000生成特殊的SQL语法。



https://entityframework.codeplex.com/SourceControl/latest#src/EntityFramework.SqlServer/SqlGen/TopClause.cs

  public void WriteSql(SqlWriter writer,SqlGenerator sqlGenerator)
{
writer.Write(TOP);

if(sqlGenerator.SqlVersion
!= SqlVersion.Sql8)
{
writer.Write(();
}
.....

类似于这些类,还有其他有特殊注意事项的SQL Server 2000?知道SQL Server 2000是否在EF 6中正式支持?



感谢

解决方案

虽然有代码来处理SQL Server 2000,但是有一些有效的查询实体框架根本无法转换为任何形式的SQL将被该版本的SQL Server接受,这样的查询将导致运行时异常。完全相同的查询在为SQL Server 2005或更高版本构建的模型上起作用。主要的限制是在该版本的SQL中没有获得 APPLY 的效果的好方法服务器。



基本上,您可以使用EF与SQL Server 2000,但它不如新版本有用,您需要以确保您的应用程序使用的每个查询实际上都经过测试,因为它编译的事实并不意味着它将工作。



另外,设计者明确检查SQL Server版本并拒绝SQL Server 2000。


Anybody knows if SQL Server 2000 is supported in EF 6 for Code First? In the official websites I haven't found anything about which SQL Server versions are supported in EF 6. In some blogs I've found that SQL Server 2000 is not supported, but these blogs aren't from official sources. Looking at the source code of EF 6 it seems that is supported I've found some code with SQL Server 2000 considerations.

For example:

SqlVersion is a class with an enum of SQL Server versions, SQL Server 2000 is in this enum.

https://entityframework.codeplex.com/SourceControl/latest#src/EntityFramework.SqlServer/SqlVersion.cs

// <summary>
// This enumeration describes the current SQL Server version.
// </summary>
internal enum SqlVersion
{
    // <summary>
    // SQL Server 8 (2000).
    // </summary>
    Sql8 = 80,

    // <summary>
    // SQL Server 9 (2005).
    // </summary>
    Sql9 = 90,
    .....

TopClause is the class that generates a select TOP clause, in this class in the method WriteSql, special SQL syntax is generated for SQL Server 2000.

https://entityframework.codeplex.com/SourceControl/latest#src/EntityFramework.SqlServer/SqlGen/TopClause.cs

    public void WriteSql(SqlWriter writer, SqlGenerator sqlGenerator)
    {
        writer.Write("TOP ");

        if (sqlGenerator.SqlVersion
            != SqlVersion.Sql8)
        {
            writer.Write("(");
        }
        .....

And like theses class there are others with special considerations for SQL Server 2000? Anybody know if SQL Server 2000 is official supported in EF 6?

Thanks

解决方案

Although there is code to handle SQL Server 2000, there are valid queries that Entity Framework simply cannot translate to any form of SQL that will be accepted by that version of SQL Server. Such queries will result in run-time exceptions. The exact same queries do work on a model built for SQL Server 2005 or newer. The main limitation is that there is no good way of getting the effect of APPLY in that version of SQL Server.

Basically, you can use EF with SQL Server 2000, but it's less useful than on newer versions, and you need to make sure that each and every query your application uses actually gets tested, because the fact that it compiles doesn't mean that it will work.

Also, parts of the designer explicitly check for the SQL Server versions and reject SQL Server 2000.

这篇关于实体框架6支持SQL Server 2000?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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