Object 6 structure and spatial data

I have a database with spatial data types. I am using the first database model and entity framework 6.0.2 and .NET 4.5. When I try to use the generated classes, I get the following error:

The specified schema is invalid. Errors: The association "Name_FK1" was not loaded because the type "Model.TypeB" is not available. The following information may be useful in resolving a previous error: The Position property in the Data.TypeB type has the property type System.Data.Spatial.DbGeography, which cannot be mapped to a primitive type.

The same error is indicated for all tables where I use the spatial type. "Name_FK1" is the relation of foreign keys.

What am I doing wrong?

Thank you for your help.

+7
c # entity-framework spatial
source share
3 answers

I fixed it! I'm very proud of myself :)

Hope this helps someone else. So, the link above ( http://msdn.microsoft.com/en-US/data/dn469466 ) has this line:

Spatial classes (e.g. DbGeography, DbGeometry) have moved from System.Data.Spatial => System.Data.Entity.Spatial

Before I got this error:

The relationship "IntakeModel.FK_Assignee_HomeLocation" was not loaded because the type "IntakeModel.Location" is not available. The following information may be useful in resolving a previous error: The "Geo" property in the "ConsoleApplication3.Location" type has the property type 'System.Data.Spatial.DbGeography', which cannot be mapped to a primitive type.

I just had to change this in my Location.cs file:

public System.Data.Spatial.DbGeography Geo { get; set; } 

For this:

 public System.Data.Entity.Spatial.DbGeography Geo { get; set; } 

The problem is resolved. Thanks for posting this link @Ricky Jones.

+21
source share

I followed the instructions at the following link, which caused other problems that I needed to solve, but this fixed my spatial problem.

http://msdn.microsoft.com/en-US/data/dn469466

+5
source share

This problem was caused by the fact that you created the EF 5.x DbContext Generator for EF 6.0 edmx to solve this problem you just need to remove the old DbContext generator and create a new one with the EF 6.0 DbContext Generator.

It worked for me.

+1
source share

All Articles