'Microsoft.SqlServer.Types' version 10 or higher could not be found on Azure

asp.net-mvc azure entity-framework

Question

In ASP.NET MVC 4, I'm attempting to create a web API. Entity Framework 5 Spatial classes were utilized in the web API, and I created pretty basic code.

  public List<Area> GetAllAreas()
    {
        List<Area> aList = db.Areas.ToList();
        return aList;
    }

There is DbGeometry in Area.

This works when I run it locally, however when I publish it to Azure, I get the following error:

Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found.

Anyone know how to resolve this ? :)

Thanks!

1
94
11/1/2012 9:28:37 AM

Accepted Answer

I discovered the answer! Simply set up the Microsoft.SqlServer.Types nuget package.

PM> Install-Package Microsoft.SqlServer.Types

Informational link

126
11/17/2016 3:31:33 PM

Popular Answer

When version 11 (SQL Server 2012) of the assembly may be utilized, the answer above functions as intended.

This was a challenge for me since my solution also relies on version 13 (SQL Server 2016) of the same assembly. In this instance, it should be noted that Entity Framework (at least v6.1.3) is hardcoded to only check for versions 10 and 11 of the assembly in its SqlTypesAssemblyLoader (the cause of this issue).

I learned that you can tell Entity Framework which assembly you want to use by saying something like this:

SqlProviderServices.SqlServerTypesAssemblyName = typeof(SqlGeography).Assembly.FullName;


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