Problems with caching DbGeography DB type

May 29, 2014 at 2:17 PM

Do you know if DBGeography DB type is supported?

I have some issues retrieving property mapped to that data type and want to be sure if I have done something wrong or not.

Jun 2, 2014 at 6:21 AM
Hi Lyubomir,

Do spatial types work without the cache in your app? There isn't anything I can think of that would block spatial types but if they work without caching then it feels like a bug in which case you need to create a new work item and include a simplified repro and I will take a look.

Jun 4, 2014 at 9:55 PM
Edited Jun 4, 2014 at 9:56 PM
Hi Pawel,

Just to give you more information regarding the error which I am getting:

{"Spatial readers can only be produced from readers of type SqlDataReader. A reader of type EFCache.CachingReader was provided."}

Please check the screenshot

This is from MVCForum

They are using your caching mechanism, but I added a spatial field in one of the entities there and stopped working.

Kind Regards,
Jun 5, 2014 at 5:26 AM
Hi Lyubomir,

Thanks for posting the details. They are very helpful. I looked briefly at the code and I kind of understand what's going on but am still not sure if this is a bug in the EF Cache or the SqlServer provider (or in both places). SqlServer provider expects SqlDataReader but since the results were cached we no longer have SqlDataReader but a DbReader class derived instance. If I can successfully override the GetSpatialReader method in database agnostic way to return a custom SpatialDbDataReader created from the cached results then the bug is only in EFCache since it does not handle this case correctly. If I cannot then there is a bigger issue that might need to be fixed in EF. I am pretty busy right now but will try to take a look at this in a couple of weeks. I will create a work item to track this issue.

Aug 21, 2014 at 5:06 AM
To close the loop - there is a design flaw in EF due to which it’s impossible to use spatial types with a wrapping provider if result buffering is turned on. For more details take a look at this bug: