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

Implement support for the new SQL Server native JSON type #32150

Closed
5 tasks done
roji opened this issue Oct 24, 2023 · 1 comment · Fixed by #34401
Closed
5 tasks done

Implement support for the new SQL Server native JSON type #32150

roji opened this issue Oct 24, 2023 · 1 comment · Fixed by #34401
Labels
area-json area-sqlserver closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Milestone

Comments

@roji
Copy link
Member

roji commented Oct 24, 2023

SQL Azure now has the new JSON type as a public preview (docs); the type will also appear in the next on-premise SQL Server version. We should ensure support for this in EF. We likely want to wait until some sort of on-premise SQL Server supports this.

External things we depend on

  • [ ] We're blocked until we're provided a SqlClient version that supports the new JSON type (tracking issue).
    • We can release without a dependency on the new SqlClient. We just need the SqlDbType value from the BCL.
  • SqlDbType.Json is being exposed in the runtime for .NET 9.0 (issue). EF will presumably need to use that to specify to SqlClient to send the new JSON type.

TODO

  • Implement type mapping support for mapping .NET string to the new json type.
  • Allow users to map primitive collections to the new JSON type (by explicitly configuring the column type - we'll consider switching the default later).
  • Json: add ability to specify type of the json column #28452 (to allow users to map owned entity types to the new JSON type).
  • Test-wise, we'd ideally duplicate the PrimitiveCollections and other JSON-related tests to also execute when configured with json. Though note that the JSON type is currently only available in SQL Azure, and we don't currently test against it, as there's no local emulator version.

/cc @saurabh500

@roji
Copy link
Member Author

roji commented May 26, 2024

The JSON feature seems to be out (as preview) on Azure SQL, see docs.

Some things to think about:

  • Should/can we switch to mapping to the new type by default (as opposed to nvarchar(max))?
    • The type is currently only available on Azure SQL, and not on any on-prem SQL Server version. If we decide to change the default, we can do that only when the user uses the new UseAzureSql() instead of UseSqlServer() (not yet implemented, see Introduce UseAzureSql/UseAzureSynapse as alternatives to UseSqlServer #33816).
    • We'd need to carefully think of the migration path for users with existing databases, e.g. is it possibly to automatically migrate existing nvarchar(max) columns to the new json type (and is this something we actually want).
    • This would apply to both owned entity types and primitive collections (which are mapped to JSON columns).
    • Specifically for complex types, we don't currently support mapping these to JSON so it may be easier to map to the new JSON type (no breaking change).

@roji roji changed the title Investigate compatibility with the new SQL Server native JSON type Implement support for the new SQL Server native JSON type Jun 26, 2024
@roji roji added the blocked label Jun 26, 2024
@roji roji modified the milestones: Backlog, 9.0.0 Jun 26, 2024
ajcvickers added a commit that referenced this issue Aug 11, 2024
Fixes #28452
Fixes #32150

Remaining work:

- Test reverse engineering from an existing database
- Output a warning when the native JSON type is used
- Replace the ToJson overload with HasColumnType()
- Move the type mapping visitation to another visitor

Known issues:

- Various issues communicated with the SQL team--see TODO:SQLJSON
- Testing is disabled until we have an appropriate server and driver to test against
ajcvickers added a commit that referenced this issue Aug 11, 2024
Fixes #28452
Fixes #32150

Remaining work:

- Test reverse engineering from an existing database
- Output a warning when the native JSON type is used
- Replace the ToJson overload with HasColumnType()
- Move the type mapping visitation to another visitor

Known issues:

- Various issues communicated with the SQL team--see TODO:SQLJSON
- Testing is disabled until we have an appropriate server and driver to test against
ajcvickers added a commit that referenced this issue Aug 12, 2024
Fixes #28452
Fixes #32150

Remaining work:

- Test reverse engineering from an existing database
- Output a warning when the native JSON type is used
- Replace the ToJson overload with HasColumnType()
- Move the type mapping visitation to another visitor

Known issues:

- Various issues communicated with the SQL team--see TODO:SQLJSON
- Testing is disabled until we have an appropriate server and driver to test against
ajcvickers added a commit that referenced this issue Aug 12, 2024
Fixes #28452
Fixes #32150

Remaining work:

- Test reverse engineering from an existing database
- Output a warning when the native JSON type is used
- Replace the ToJson overload with HasColumnType()
- Move the type mapping visitation to another visitor

Known issues:

- Various issues communicated with the SQL team--see TODO:SQLJSON
- Testing is disabled until we have an appropriate server and driver to test against
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Aug 12, 2024
ajcvickers added a commit that referenced this issue Aug 13, 2024
Fixes #28452
Fixes #32150

Remaining work:

- Test reverse engineering from an existing database
- Output a warning when the native JSON type is used
- Replace the ToJson overload with HasColumnType()
- Move the type mapping visitation to another visitor

Known issues:

- Various issues communicated with the SQL team--see TODO:SQLJSON
- Testing is disabled until we have an appropriate server and driver to test against
ajcvickers added a commit that referenced this issue Aug 14, 2024
Fixes #28452
Fixes #32150

Remaining work:

- Test reverse engineering from an existing database
- Output a warning when the native JSON type is used
- Replace the ToJson overload with HasColumnType()
- Move the type mapping visitation to another visitor

Known issues:

- Various issues communicated with the SQL team--see TODO:SQLJSON
- Testing is disabled until we have an appropriate server and driver to test against
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-rc1 Aug 21, 2024
@ajcvickers ajcvickers removed their assignment Aug 31, 2024
@roji roji modified the milestones: 9.0.0-rc1, 9.0.0 Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-json area-sqlserver closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants