Reputation: 12712
I am having a few problems loading a table into the designer. I get the following error.
One or more selected items contain a data type that is not supported by the designer
Would I be correct in assuming it is the geography type used in the table that is causing this error?
Any pointers much appreciated.
Upvotes: 8
Views: 4639
Reputation: 21175
I have a project (a small one, granted) that grew to have new requirements for spatial types. I decided to see how easy it would be to upgrade to entity framework from LINQ to SQL.
It took me no more than 30 minutes. Make sure you have a source control backup before you start.
Install-Package EntityFramework -Version {pick one}
.dbml
file(s)metadata=res://*/;provider=System.Data.SqlClient;provider connection string='Data Source=.\SQLEXPRESS; Initial Catalog=MyDataBase; Integrated Security=True'
Insert/DeleteOnSubmit
and EF's Add/Remove
or Add/RemoveRange
. Transaction scopes may work differently (consider using context.Database.BeginTransaction
instead of transaction scopes).That's it. It was much easier than I expected and now I can use the spatial types without any trickery.
Upvotes: 1
Reputation: 905
To correct this error:
or see this article The Missing Linq to SQL Spatial,This article provides hints and hacks on how to use the SQL Server spatial data types -Geography and Geometry- in Linq to SQL
Upvotes: 3
Reputation: 176956
Check below article / answer for the detail :
Is it possible to use SqlGeography with Linq to Sql?
Spatial types are not supported by Linq to SQL. Support is not "not great" - it's nonexistent.
You can read them as BLOBs, but you can't do that by simply changing the column type in Linq to SQL. You need to alter your queries at the database level to return the column as a varbinary, using the CAST statement. You can do this at the table level by adding a computed varbinary column, which Linq will happily map to a byte[].
Upvotes: 1