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

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

问题描述

我有一台全新的服务器,我在上面安装了 .NET 4.5 Beta 可再发行版.尝试使用空间特征时出现 NotImplemented 异常.这段代码...

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

抛出这个异常...

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

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

If I install the full VS.NET 11 Beta then the code works fine. Any ideas why? What is missing?

更新答案

感谢帕维尔.您需要安装 SQL CLR 类型.您可以通过以下链接获取 2012 版:

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

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

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

意见

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

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.

推荐答案

Entity Framework 中的 DefaultSpatialServices 使用 SqlGeography 和 SqlGeometry 类型作为支持类型.这两种类型存在于 Microsoft.SqlServer.Types.dll 程序集中,它不是 .NET Framework 的一部分.当 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 的类型,因此安装哪个版本无关紧要.

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.

编辑

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

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

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

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

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

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