Does EF 6 support SQL Server 2014 Types?

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


I need to convert a file in an 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=, Culture=neutral, PublicKeyToken=89845dcd8080cc91'.
Parameter name: providerValue

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

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

//EntityFramework.SqlServer.dll( System.Data.Entity.SqlServer.SqlTypesAssemblyLoader
public SqlTypesAssemblyLoader(IEnumerable<string> assemblyNames = null)
    this._preferredSqlTypesAssemblies = (assemblyNames ?? ((IEnumerable<string>)new string[]
        "Microsoft.SqlServer.Types, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91",
        "Microsoft.SqlServer.Types, Version=, 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?

9/29/2015 4:37:09 AM

Accepted Answer

9/29/2015 5:28:15 AM

Related Questions


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