Spatial types and functions are not available for this provider

entity-framework-6 sql sql-server visual-studio-2015

Question

I have Update 3 for Visual Studio 2015 Community Edition. Entity Framework 6 is what I'm using. When I run the project locally, I see the error indicated in the screen photo (https://puu.sh/uXFh0/64648902af.png). As c.Geography is used in my code, it throws an error at that moment.

My computer is running SQL Server 2016 with CLR Types installed, as can be seen in the screen photo below (https://puu.sh/uXFqy/9f3c56a329.png).

Using the nuget package Install-Package Microsoft.SqlServer.Types, I also installed SQL server types.

I've had no success. What more can I do to address this situation?

1
0
3/25/2017 5:49:27 AM

Popular Answer

You must instruct your programme which version of the CLR types to use since you have many versions installed. I'm unsure of the kind of application, but you must either add the following lines of code to your global.asax.cs (web app) file:

SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
SqlProviderServices.SqlServerTypesAssemblyName = "Microsoft.SqlServer.Types, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91";

Alternatively, display this in your desktop app before the spatial code runs:

SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
SqlProviderServices.SqlServerTypesAssemblyName = "Microsoft.SqlServer.Types, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91";
1
3/28/2017 3:57:23 PM


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