Entity Framework 6 supports SQL Server 2000?
Asked Answered
T

2

9

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

Tentacle answered 11/8, 2014 at 9:38 Comment(0)
T
8

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.

Teague answered 11/8, 2014 at 9:45 Comment(0)
Y
12

Yes, you can use EF 6.x for SQL Server 2000, I'm using this for SQL Server 2000 without any problems.

But your should set something in your .edmx file of your model.

Open your model .edmx file with notepad or any text editor, then change this line :

<Schema Namespace="MyModel.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2000" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">

As you can see, ProviderManifestToken="2000" shows your SQL Server version.EF look this section for generating T-SQL queries and generate scripts under the version.

Yeseniayeshiva answered 11/8, 2014 at 9:46 Comment(0)
T
8

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.

Teague answered 11/8, 2014 at 9:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.