Entity Framework not getting Spatial type data in result from Sql Server stored procedure

I’m using Entity Framework 6 with .Net 4.5. I have a stored procedure that selects and returns data. One of the return columns is a geography type.
In Visual Studio 2015, I right click the .edmx file, click “Update Model From Database…”. This action gets my stored procedure and creates a complex type of storeprocedurename_Result. All the columns are represented in the complex type objects except the geography type.

At the same time one of my table also have Geography type but that table is retrieved successfuly with the geography column and it is functioning properly. So, i can guess geography type is supported in EF and is working.
But i don’t know why it is not generating that type for me in the complex type generated.
I tried manually adding public System.Data.Entity.Spatial.DbGeography col_name { get; set; } but it got null in results.
For the record i have tried executing the procedure in Sql Server management studion and that column is present there. So, its problem on EF end not DB end.
I have searched and got a couple of questions like these, but it seems no one is able to answer them.
I was not able to understand the response on this question.

  • Is Entity Framework tied to SQL Server?
  • How to concatenate two strings in SQL Server 2005
  • Measure application performance by aggregating SQL audit records
  • How do you migrate SQL Server Database Diagrams to another Database?
  • SQL Server: Select multiple records in one select statement
  • Setting Report date parameters
  • and it is one on stackoverflow
    The person asking above question has used a workaround as he says in comment “No. I don’t think you can automatically get the geography type. Because when you view the results in the model browser it says “Not supported”. To get around this issue, my stored proc converts the geography type to a string via [pro_GeoLocation].STAsText() as pro_GeoLocationPoint. Then I use a regex in my C# code to get the long and lat.” But this is not a good option and there must be a solution to this.

  • How can you configure or extend BITS (Background Intelligent Transfer Service) to read files from a Sql Server Database
  • Algorithm to avoid SQL injection on MSSQL Server from C# code?
  • Creating snapshot of application data - best practice
  • Streaming byte to Image in ASP.NET C#
  • retrieve data from SQL server depending on value of combo box in datagridview in c#
  • How to save a file path at database?
  • One Solution collect form web for “Entity Framework not getting Spatial type data in result from Sql Server stored procedure”

    As i was expecting (seeing previous posts like this) there was no answer to this problem, so now when i have solved the problem, i will linke to share the solution which got me the geography object.

    I tried many things and tried many solution, i dropped my procedure and SP entry from edmx many times. And re created but all in vain!
    Than what worked was so simple… following the link below i just opened edmx, than open model browser, in model browser go to your complex type defination which is missing the column, right click add->scalar property->geography. And give it the name precisely which is retured by stored procedure.
    Thats it, save the changes and run your code, you must get your data properly as i am getting.
    I am wondering why EF was not able to get the the data and on getting column information of the function/SP it mentioned EDM type unsupported. Strage!

    Ref: http://www.scriptscoop.net/t/7c1ed5a0f89e/entity-framework-5-function-import-with-spatial-data.html

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.