Visual Studio 2010 数据库项目无法识别 SQL 2008 地理数据类型

发布于 2024-09-01 02:56:07 字数 528 浏览 4 评论 0 原文

我在 Visual Studio 2010 中创建了一个新的 SQL 2008 数据库项目,并用本地 SQL Express 数据库的内容填充它。当我尝试构建数据库项目时,出现此错误: SQL03006:列:[dbo]。[table1]。[geog]对Sql类型[dbo]。[geography]有一个未解析的引用

我已经做了一些搜索,它可能缺少对Microsoft.SqlTypes.dbschema的引用,但是我在任何地方都找不到: http://www.incyclesoftware.com/blog/post/2009/07/07/Resolve-references-Error-TSD03006-IN-VSTS-DB-GDR.aspx

是数据类型确实不支持开箱即用,还是我遗漏了一些东西?

I've created a new SQL 2008 database project in Visual Studio 2010 and filled it with the contents of a local SQL Express database. When I try to build the database project I get this error:
SQL03006: Column: [dbo].[table1].[geog] has an unresolved reference to Sql Type [dbo].[geography]

I've done some searching and it may be missing a reference to Microsoft.SqlTypes.dbschema, but I can't find that anywhere: http://www.incyclesoftware.com/blog/post/2009/07/07/Resolve-references-Error-TSD03006-IN-VSTS-DB-GDR.aspx

Is the datatype really not supported out of the box or am I missing something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

酒浓于脸红 2024-09-08 02:56:07

找到了;在表或存储过程中,数据类型需要以 [sys] 为前缀,如下所示:

CREATE TABLE [dbo].[Location] (
    [objectId]  BIGINT            NOT NULL,
    [latitude]  FLOAT             NOT NULL,
    [longitude] FLOAT             NOT NULL,
    [geog]      [sys].[geography] NULL,
    [geom]      [sys].[geometry]  NULL
);

Found it; in the table or stored procedure the datatype needs to be prefixed with [sys] like this:

CREATE TABLE [dbo].[Location] (
    [objectId]  BIGINT            NOT NULL,
    [latitude]  FLOAT             NOT NULL,
    [longitude] FLOAT             NOT NULL,
    [geog]      [sys].[geography] NULL,
    [geom]      [sys].[geometry]  NULL
);
陪你到最终 2024-09-08 02:56:07

在将 Sql 类型几何引入数据库项目后,我遇到了同样的问题(在我的例子中,当我与 SQL 2008 架构进行比较时,数据库项目版本设置为“2005”)

我通过更改数据库项目版本(属性)解决了该问题-> 项目设置 -> 项目版本)到 2008。

之后,当您右键单击“引用”(对于数据库项目)或项目本身时,您应该会看到一个选项“添加 SQL Server 2008 CLR 类型”。这将添加您需要的参考并解决问题。

以下是为我添加在 proj XML 中生成的引用的内容:

;
    
         ..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 9.0\VSTSDB\Extensions\SqlServer\2008\DBSchemas\Microsoft.SqlTypes.dbschema
   

I have had the same issue after introducing Sql Type geometry to a DB Project (DB project version in my case was set to "2005" while I was comparing to a SQL 2008 schema)

I resolved the issue by changing the Database Project Version (Properties -> Project Settings -> Project Version) to 2008.

After that when you right-click on References (for the Database Project) or the project itself, you should see an option "Add SQL Server 2008 CLR Types". This will add the reference that you need and will resolve the issue.

Here is what adding the reference generated in the proj XML for me:

<ItemGroup>
    <ArtifactReference Include="$(VSTSDBDirectory)\Extensions\SqlServer\2008\DBSchemas\Microsoft.SqlTypes.dbschema">
         <HintPath>..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 9.0\VSTSDB\Extensions\SqlServer\2008\DBSchemas\Microsoft.SqlTypes.dbschema</HintPath>
   </ArtifactReference>
</ItemGroup>
断爱 2024-09-08 02:56:07

我从未获得“添加 SQL Server 2008 CLR 类型”选项,但我能够通过编辑 .dbproj 文件并将 LoadSqlClrTypes 值更改为 True 来解决此问题:

<LoadSqlClrTypes>True</LoadSqlClrTypes>

I never got the "Add SQL Server 2008 CLR Types" option, but I was able to fix this problem by editing my .dbproj file and changing the LoadSqlClrTypes value to True:

<LoadSqlClrTypes>True</LoadSqlClrTypes>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文