3

I'm using Entity Framework 6 with .Net 4.5. I have a stored procedure that select and returns data. One of the return columns is a geography type.

In Visual Studio 2013, 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.

I don't want to manually modify the complex type. I want to get it automatically via clicking "Update Model From Database...". Does Entity Framework 6 support this? And what are the step to implement this feature?

rosieBCPD1
  • 51
  • 3
  • Did you find a way to get the geography type correctly generated ? I encounter the same problem that you got. – Julien Coqueret Mar 01 '15 at 16:27
  • 1
    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. – rosieBCPD1 Mar 02 '15 at 19:14
  • I think this is not a proper solution but this is a workaround which should be working...
    I have also posted a similar question here: http://stackoverflow.com/questions/34413287/entity-framework-not-getting-spatial-type-data-in-result-from-sql-server-stored
    In case someone might be looking for the solution and that question gets the proper answer...
    – Zia Ul Rehman Mughal Dec 22 '15 at 10:20

1 Answers1

1

Entity Framework won't handle this automatically, but it's pretty simple to add the geography column after the procedure is imported.

  1. In the Model Browser, search or navigate to your stored procedure's complex type. Right-click, and select Add -> Scalar Property -> Geography (or any other type that you are missing):

    enter image description here

  2. Enter the name of your column:

    enter image description here

  3. Save your model.

Chris Schiffhauer
  • 17,102
  • 15
  • 79
  • 88