Does EF 6 support SQL Server 2014 Types?

.net c# entity-framework entity-framework-6 sql-server-2014

Question

I need to convert a file in an asp.net mvc 5 web api application.SqlGeography example into aDbGeography instance for Entity Framework 6 querying. To do this, I'm employing the following code:

SqlGeography geo = SqlGeography.STGeomFromText(chars, Constants.SRID);
DbGeography dbGeo = DbSpatialServices.Default.GeographyFromProviderValue(geo);

called forGeographyFromProviderValue flings the subsequent exception:

The specified provider value is not compatible with this spatial services implementation. A value is required of type 'Microsoft.SqlServer.Types.SqlGeography, Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'.
Parameter name: providerValue

Certainly, mySqlGeography the SQL Server 2014 types assembly, for example (Microsoft.SqlServer.Types, Version 12.0.0.0 ).

Investigating the Entity Framework source code reveals that this method is to blame:

//EntityFramework.SqlServer.dll(6.0.0.0) System.Data.Entity.SqlServer.SqlTypesAssemblyLoader
public SqlTypesAssemblyLoader(IEnumerable<string> assemblyNames = null)
{   
    this._preferredSqlTypesAssemblies = (assemblyNames ?? ((IEnumerable<string>)new string[]
    {
        "Microsoft.SqlServer.Types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91",
        "Microsoft.SqlServer.Types, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
    }));
        this._latestVersion = new Lazy<SqlTypesAssembly>(new Func<SqlTypesAssembly>(this.BindToLatest), true);
    }
}

As you can see, SQL Server 2014's types assembly is not present. Does this imply that SQL Server 2014 types are not supported by Entity Framework 6?

The Types assembly for SQL Server 2012 is available, so I could use that instead, but I'd prefer not to. Is there another solution to this problem?

1
8
9/29/2015 4:37:09 AM

Accepted Answer

ZZZ_tmp
6
9/29/2015 5:28:15 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow