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

Solution 1:

I found the solution ! Just install the nuget package Microsoft.SqlServer.Types

PM> Install-Package Microsoft.SqlServer.Types

Link for more info

Solution 2:

The answer above works fine when version 11 (SQL Server 2012) of the assembly can be used.

I had a problem with this as my solution has other dependencies on version 13 (SQL Server 2016) of the same assembly. In this case note that Entity Framework (at least v6.1.3) is hardcoded in its SqlTypesAssemblyLoader (the source of this exception) to only look for versions 10 and 11 of the assembly.

To work around this I discovered you can tell Entity Framework which assembly you want to use like this:

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

Solution 3:

For some reason I was missing a binding redirect which fixed this problem for me.

Adding the following fixed my problem

    <dependentAssembly>
      <assemblyIdentity name="Microsoft.SqlServer.Types" publicKeyToken="89845dcd8080cc91" culture="neutral" />
      <bindingRedirect oldVersion="10.0.0.0-11.0.0.0" newVersion="14.0.0.0" />
    </dependentAssembly>

Solution 4:

There are 2 ways to fix that:

  1. If you have server access, just Install “Microsoft System CLR Types for SQL Server 2012” it’s from https://www.microsoft.com/en-us/download/details.aspx?id=29065 Or Use Direct Link Below Direct Link to X86 :http://go.microsoft.com/fwlink/?LinkID=239643&clcid=0x409 , Or Direct Link to X64 :http://go.microsoft.com/fwlink/?LinkID=239644&clcid=0x409
  2. Second way is to use NuGet package manager and install

    Install-Package Microsoft.SqlServer.Types

Then follow the plugin notes as below

To deploy an application that uses spatial data types to a machine that does not have 'System CLR Types for SQL Server' installed you also need to deploy the native assembly SqlServerSpatial110.dll. Both x86 (32 bit) and x64 (64 bit) versions of this assembly have been added to your project under the SqlServerTypes\x86 and SqlServerTypes\x64 subdirectories. The native assembly msvcr100.dll is also included in case the C++ runtime is not installed.

You need to add code to load the correct one of these assemblies at runtime (depending on the current architecture).

ASP.NET applications For ASP.NET applications, add the following line of code to the Application_Start method in Global.asax.cs:

SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));

Desktop applications For desktop applications, add the following line of code to run before any spatial operations are performed:

SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);