Rusty Nguyen
Rusty Nguyen

Reputation: 41

Schema specified is not valid. Errors: 'System.Data.Spatial.DbGeography' which cannot be mapped to a primitive type

I'm doing Entity Framework (v6) db first. I get the following error when trying to access data from my datacontext. The relationship 'Model.FK_Table1_Table2' was not loaded because the type 'Model.Table1' is not available. The following information may be useful in resolving the previous error: The property 'Location' on the type 'Model.Table1' has a property type of 'System.Data.Spatial.DbGeography' which cannot be mapped to a primitive type.

Any idea what is causing this error?

Upvotes: 4

Views: 1685

Answers (2)

Sharad Tiwari
Sharad Tiwari

Reputation: 31

Probably you need to see the solution on this url https://msdn.microsoft.com/en-US/data/dn469466

I have fixed same problem after updating some content of my code from mentioned url page there they have given solution for update to EF-5 to EF-6 after updating some of references on my context class. it is working fine.

Upvotes: -1

Eric
Eric

Reputation: 2283

I don't know if this is your problem, but I had a similar error when I upgraded from EF5 to EF6. The spatial data types moved namespaces. This link has all the info:

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

Boiled down, you need to:

  1. Install EF6
  2. Update any namespace/using statements
  3. Remove references to System.Data.Entity
  4. (Probably) refresh your EF diagram.

Upvotes: 2

Related Questions