I have an entity with some spatial data... I am using DbGeography
and DbGeometry
referenced in the System.Data.Entity
assembly...
I am not using that one referenced in EntityFramework.dll
because I have a layered solution and I do not want to reference Entity Framework everywhere in my solution, but just inside the DAL...
When I try to add a new migration I get the following error:
EntityType 'DbGeometry' has no key defined. Define the key for this EntityType.
So I tried to replace the DbGeometry
property with a string OnModelCreating
I have tried to write the following code:
modelBuilder.Entity<AddressInfo>()
.Property(s => s.GeometryLocation)
.HasColumnType("geometry");
But In this case I receive the error that the String data type is not compatible with the DbGeometry
data type...
Does anyone have any idea to solve this problem? Does anyone know which data type is compatible with DbGeometry
data type?
Thank you
UPDATE
EntityType 'DbGeography' has no key defined does not solve my problem.. At the end, the author of the post says that
[He] literally had to add a reference to Entity Framework in [his] model
This is exactly what I want to avoid...
Ryan also says that
I think it may be fixable with a clever data configuration map though, I'll be playing with it and will update if I run across any workable techniques
Any idea how to fix it? Which could be a compatible data type to replace DbGeometry?