.NET 4.5 Beta DbGeography NotImplementedException

I have a completely new server on which I installed the beta version of .NET 4.5. When I try to use spatial functions, I get a NotImplemented exception. This code ...

var x = DbGeography.PointFromText(string.Format("POINT({0} {1})", -45, 45), 4326); 

Throws this exception ...

 System.NotImplementedException: The method or operation is not implemented. at System.Data.Spatial.DefaultSpatialServices.GeographyPointFromText(String geographyText, Int32 spatialReferenceSystemId) 

If I install the full version of VS.NET 11 Beta, then the code will work fine. Any ideas why? What is missing?

UPDATE FOR ANSWER

Thanks to Pavel. You must install the SQL CLR types. You can get version 2012 from this link:

CLR Types for Microsoft® System for Microsoft® SQL Server® 2012 http://www.microsoft.com/download/en/details.aspx?id=29065

OPINION

I really don't understand why the .NET platform is dependent on SQL Server. There is nothing special about these classes. I understand that this is probably a historical thing when the code was originally written by the SQL team and the .NET team wanted to reuse it. It is not clear that this is also a provider-based implementation. A better exception message would save a day's work.

+6
source share
4 answers

The DefaultSpatialServices in the Entity Framework use the SqlGeography and SqlGeometry types as support types. These two types live in the Microsoft.SqlServer.Types.dll assembly, which is not part of the .NET Framework. An exception occurs when EF cannot find these types (an exception may be more useful ...). When you install Visual Studio, it will install localdb on your computer (or you may have a SqlExpress database), and this is probably the way you got the type on a working computer. On a computer where only the .NET Framework and not Sql Server is installed, you will not have these types. You can install SqlExpress in the field where you get the exception, or you can try to install only those types. I'm not sure where to get the assembly, but I think that the Sql Server function package ( http://www.microsoft.com/en-us/download/details.aspx?id=27596 ) can have this. Types from SqlServer 2008 and SqlServer 2012 are supported, so it does not matter which version you are installing.

EDIT

In EF6, the exception will contain the best message: https://entityframework.codeplex.com/SourceControl/changeset/b3eca2c141c0fb517504f9731dc8ba7a9c5727ee

Work item used to track this error: https://entityframework.codeplex.com/workitem/3

+15
source

Maybe someone can highlight the darwindaves answer:

Install nuget package Microsoft.SqlServer.Types. Alternatively add links to:

c: \ Program Files (x86) \ Microsoft SQL Server \ 100 \ SDK \ Assemblies \ Microsoft.SqlServer.Types.dll and do not forget to mark the local copy in the properties.

+2
source

In addition to adding

c: \ Program Files (x86) \ Microsoft SQL Server \ 100 \ SDK \ Assemblies \ Microsoft.SqlServer.Types.dll

I also needed to add

SqlServerSpatial110.dll

As soon as we added those, they worked like a charm!

0
source

@Pawal's accepted answer helped solve my problem. His link to “Microsoft SQL Server 2008 Service Pack 3 for Microsoft SQL Server 2008 Service Pack 3” left me a little in the dark as to what I really needed to install on the target machine, but in the end I needed the following:

Gumileva \ x64 \ SQLSysClrTypes.msi

0
source

Source: https://habr.com/ru/post/912994/


All Articles