问题
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?
回答1:
Entity Framework won't handle this automatically, but it's pretty simple to add the geography
column after the procedure is imported.
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 the name of your column:
Save your model.
来源:https://stackoverflow.com/questions/28592085/geography-column-returned-in-stored-procedure-not-shown-in-entity-framework-auto