Visual Studio 2010 database project does not recognize SQL 2008 geography data type

I created a new SQL 2008 database project in Visual Studio 2010 and populated it with the contents of a local SQL Express database. When I try to build a database project, I get this error: SQL03006: Column: [dbo]. [Table1]. [Geog] has an unresolved Sql Type reference [dbo]. [Geography]

I did some searches and I may be missing a link to Microsoft.SqlTypes.dbschema, but I can't find anything: 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?

+2


a source to share


3 answers


Found; in a table or stored procedure, the data type must be prefixed with [sys] as follows:



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

      

+3


a source


I had the same problem after injecting Sql type geometry into a DB project (the DB project version in my case was set to "2005" when I was comparing SQL 2008 schema)

I solved the problem by changing the version of the database project (Properties -> Project Settings -> Project Version) to 2008.

After that, when you right-click the References link (for a database project) or the project itself, you should see the Add SQL Server 2008 CLR Types option. This will add the link you want and fix the problem.



This is what adds the link generated in the prog 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>

      

+2


a source


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

<LoadSqlClrTypes>True</LoadSqlClrTypes>

      

+1


a source







All Articles