.NET 4.5 Beta DbGeography NotImplementedException [英] .NET 4.5 Beta DbGeography NotImplementedException

查看:146
本文介绍了.NET 4.5 Beta DbGeography NotImplementedException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个全新的服务器,我安装了.NET 4.5 Beta可重新分发。尝试使用空间功能时,我会收到NotImplemented异常。这个代码...

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

抛出此异常...

  System.NotImplementedException:方法或操作未实现。 
在System.Data.Spatial.DefaultSpatialServices.GeographyPointFromText(String geographyText,Int32 spatialReferenceSystemId)

如果我安装完整的VS.NET 11 Beta,那么代码工作正常。任何想法为什么?缺少什么?



更新为ANSWER



感谢Pawel。您需要安装SQL CLR类型。您可以在此链接获取2012版本:



Microsoft®SQLServer®2012的Microsoft®系统CLR类型
http://www.microsoft.com/download/en/details.aspx?id=29065



OPINION



我真的不明白为什么.NET框架与SQL Server有依赖关系。这些课没有什么特别的。我意识到这可能是一个历史性的东西,代码最初由SQL团队编写,.NET团队想重用它。这不是很清楚,这也是基于提供者的实现。一个更好的异常消息可以节省一天的工作。

解决方案

实体框架中的DefaultSpatialServices使用SqlGeography和SqlGeometry类型作为后备类型。这两种类型不在.NET Framework的Microsoft.SqlServer.Types.dll程序集中。当EF找不到这些类型时会抛出异常(异常可能更有帮助...)。当您安装Visual Studio时,它将在您的计算机上安装localdb(或者您可能已经有一个SqlExpress数据库),这可能是您在机器上工作的类型。在仅安装.NET Framework的机器上,而不是Sql Server,您将不具备这些类型。您可以在收到异常的框上安装SqlExpress,也可以尝试仅安装类型。我不知道从哪里得到程序集本身,但我认为Sql Server功能包( http://www.microsoft.com/en-us/download/details.aspx?id=27596 )可能拥有它。支持来自SqlServer 2008和SqlServer 2012的类型,所以安装哪个版本不要紧。



编辑



在EF6中,异常将包含更好的消息,请参阅: https:// entityframework .codeplex.com / SourceControl / changeset / b3eca2c141c0fb517504f9731dc8ba7a9c5727ee



用于跟踪此错误的工作项: https://entityframework.codeplex.com/workitem/3


I have a brand new server which I installed the .NET 4.5 Beta redistributable on. I am getting a NotImplemented exception when trying to use the spatial features. 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 VS.NET 11 Beta then the code works fine. Any ideas why? What is missing?

UPDATE FOR ANSWER

Thanks to Pawel. You need to have the SQL CLR Types installed. You can get the 2012 version at this link:

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

OPINION

I really dont understand why the .NET framework has a dependency on SQL Server. There is nothing special about these classes. I realize this is likely a historical thing where the code was originally written by the SQL team and the .NET team wanted to reuse it. It's not very clear that this is a provider-based implementation either. A better exception message would have saved a day's work.

解决方案

DefaultSpatialServices in Entity Framework are using SqlGeography and SqlGeometry types as backing types. These two types live in Microsoft.SqlServer.Types.dll assembly that is not part of the .NET Framework. The exception is thrown when EF cannot find these types (the exception could be more helpful...). When you install Visual Studio it will install localdb on your machine (or you may already have a SqlExpress database) and this is probably the way how you got the type on the machine that is working. On a machine where there is only .NET Framework installed and not Sql Server you won't have these types. You can either install SqlExpress on the box where you get the exception or you can try installing just the types. I am not sure where to get the assembly itself but I think the Sql Server feature pack (http://www.microsoft.com/en-us/download/details.aspx?id=27596) may have it. Types from SqlServer 2008 and SqlServer 2012 are supported so it should not matter which version you install.

EDIT

In EF6 the exception will contain a better message see: https://entityframework.codeplex.com/SourceControl/changeset/b3eca2c141c0fb517504f9731dc8ba7a9c5727ee

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

这篇关于.NET 4.5 Beta DbGeography NotImplementedException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆