Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse engineer SqlClient native types: SqlGeometry, SqlGeography, and HierarchyId #10131

Closed
ajcvickers opened this issue Oct 20, 2017 · 12 comments
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. punted-for-2.1 type-enhancement

Comments

@ajcvickers
Copy link
Member

See #1100 and #10110. Since these can now be mapped on .NET Framework, it would be good if the scaffolding tool could correctly reverse engineer them. However, note:

  • They don't work with .NET Core
  • The application must be setup to reference the appropriate assemblies--EF tooling will not do this

Therefore, likely the default behavior should be to not map these types, but warn mentioning an option that can be used to turn on this mapping.

@bricelam
Copy link
Contributor

bricelam commented Jan 30, 2018

Design notes

When mapping the column types to CLR types, we can try and load the Microsoft.SqlServer.Types assembly. If the connection string contains Type System Version=SQL Server 2012, we'll try to load version 11.0.0.0; otherwise, we'll try version 10.0.0.0. (This is the SqlClient behavior.) If we can't load it, we won't map the columns.

This requires the user to add the appropriate reference and binding redirects before reverse engineering. Otherwise, these columns won't get scaffolded.

Obviously, the assembly will never load on .NET Core since one isn't available. The warning message should probably be different than on .NET Framework, since there is no way to map them. On .NET Framework, we can suggest installing/referencing the assembly if they want to map these columns.

@ErikEJ
Copy link
Contributor

ErikEJ commented Jan 30, 2018

How will scaffolding know the .net variety? Is it not fw agnostic, basically dropping files in a folder?

@bricelam
Copy link
Contributor

It knows the target framework of the project it's working with.

@bricelam
Copy link
Contributor

bricelam commented Jan 30, 2018

But I see your point. Your tool is always running as .NET Framework. Maybe we can provide an internal flag for you to always disable it.

@ErikEJ
Copy link
Contributor

ErikEJ commented Jan 31, 2018

Thanks, Brice! (An option to disable/enable would be great)

@dotMorten
Copy link

This does most of the creating and reading the types: https://github.com/dotMorten/Microsoft.SqlServer.Types
(note: No support for the spatial operations)

@ajcvickers ajcvickers changed the title Reverse engineer SqlGeometry, SqlGeography, and HierarchyId Reverse engineer SqlGeometry, SqlGeography, and HierarchyId to SQL Client types May 18, 2018
@ajcvickers ajcvickers changed the title Reverse engineer SqlGeometry, SqlGeography, and HierarchyId to SQL Client types Reverse engineer SqlClient native types: SqlGeometry, SqlGeography, and HierarchyId May 21, 2018
@ajcvickers
Copy link
Member Author

Note this is about reverse engineering to native types. Compare this to #12083

@stevie6410
Copy link

Hi, I am trying to use the EF Core scaffolding tool to target a FileTable in SQL Serer. But it is not able to generate the entity type. Am I missing a package to support the reverse engineering of the HierarchyId type? Or is this just not supported in the scaffolding tool?

Error message from the dotnet ef dbcontext scaffold call.

Could not scaffold the primary key for 'dbo.DocumentStoreFiles'. The following columns in the primary key could not be scaffolded: path_locator. Unable to generate entity type for table 'dbo.DocumentStoreFiles'.
The 'path_locator' is of type HierarchyId.

@bricelam
Copy link
Contributor

Not yet supported. This issue is tracking the work to enable it

@ajcvickers
Copy link
Member Author

Closing old issue as this is no longer something we intend to implement. EF Core 5 will not support .NET Framework and there is no support for SQL Server native spatial types in .NET Core.

@ajcvickers ajcvickers removed this from the Backlog milestone Nov 17, 2019
@GSPP
Copy link

GSPP commented Nov 17, 2019

@ajcvickers What is the recommended way for customers to be able to use spatial with EF at this point?

@ajcvickers
Copy link
Member Author

@GSPP See the docs

@ajcvickers ajcvickers added the closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. label Mar 10, 2022
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. punted-for-2.1 type-enhancement
Projects
None yet
Development

No branches or pull requests

6 participants