1

When trying to convert a string as below

52.0986413 5.2171528

to a variable of type DbGeometry like this

Geometry = System.Data.Entity.Spatial.DbGeometry.FromText("POINT("+preometry+")");

where Geometry is of type System.Data.Entity.Spatial.DbGeometry I get the next errormessage:

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

Even though I have Microsoft.SqlServer.Types version 11.0.2 in my project. Does anybody know what the problem could be? Thanks in advance

devKoen1
  • 179
  • 1
  • 12

1 Answers1

1

I found the answer when I reinstalled Microsoft.SqlServer.Types.

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"));

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

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

This fixed it for me

devKoen1
  • 179
  • 1
  • 12