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

Support for SQL Server sparse columns #8023

Closed
Tracked by #22953
borisdj opened this issue Mar 29, 2017 · 15 comments · Fixed by #23904
Closed
Tracked by #22953

Support for SQL Server sparse columns #8023

borisdj opened this issue Mar 29, 2017 · 15 comments · Fixed by #23904
Assignees
Labels
area-migrations 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

@borisdj
Copy link

borisdj commented Mar 29, 2017

I know I can do this with raw SQL in Up method, but can this be done with fluent API.
If it can How, and if not, are there plans to add this feature in future versions?

Further technical details

EF Core version: 1.1.1
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Windows 10
IDE: Visual Studio 2017

@smitpatel smitpatel changed the title Configure SPARSE column with fluent API ? SqlServer: Fluent API to configure a column as SPARSE column Mar 30, 2017
@smitpatel
Copy link
Member

Documentation link: https://docs.microsoft.com/en-us/sql/relational-databases/tables/use-sparse-columns

@borisdj - There is no fluent api at present.

@ajcvickers
Copy link
Member

@borisdj It would be interesting to add fluent API extension methods for this for the SQL Server provider. However, it is not a high priority for us, so putting it on the backlog. We would consider at a high-quality PR from the community for this.

@ajcvickers ajcvickers added this to the Backlog milestone Mar 31, 2017
@smitpatel smitpatel added the help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. label Apr 28, 2017
@divega divega added good first issue This issue should be relatively straightforward to fix. help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. and removed help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. good first issue This issue should be relatively straightforward to fix. labels May 31, 2019
@bricelam bricelam added the good first issue This issue should be relatively straightforward to fix. label May 31, 2019
@garfbradaz
Copy link

Hey @ajcvickers : I have some time spare on Friday, so I can give this a go?

Questions

  • Would you want this to be an PropertyBuilder extension in here for SQL Server?

https://github.com/aspnet/EntityFrameworkCore/blob/469177a49d251bb81184b42ce4cd2ffe623b345a/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs

  • Would it require a DataAnnotation to identify a SPARSE column?

@ajcvickers
Copy link
Member

@garfbradaz Yes, that's the appropriate place for the fluent API. It's fine to not have data annotation support for this--there are many places where the fluent API is the only way to configure something. Also, provider-specific attributes for mapping is a space that we haven't yet ventured into.

@ajcvickers
Copy link
Member

/cc @AndriySvyryd @bricelam @divega

@garfbradaz
Copy link

garfbradaz commented Jul 27, 2019

Smashing. @ajcvickers . Spent Friday familiarizing myself with the code (and today as well). Quite a complex beast (which is fun to learn).

Questions if I may:

  • There are some SPARSE restrictions - Do these need to be applied as a SqlServerConventionSetBuilder where appropriate?

  • I couldn't find a SQL Server implementation of Microsoft.EntityFrameworkCore.Migrations.Operations.CreateTableOperation & Microsoft.EntityFrameworkCore.Migrations.Operations.AlterTableOperation - I presume a SqlServerCreateTableOperation & SqlServerAlterTableOperation will be needed then to satisfy this feature, including the SPARSE elements.

Obviously any tests associated with the new code.

@garfbradaz
Copy link

Awesome thanks @ErikEJ

@ajcvickers ajcvickers removed the help wanted This issue involves technologies where we are not experts. Expert help would be appreciated. label Aug 5, 2019
@henrikdahl8240
Copy link

Has Entity Framework Core come to support SPARSE columns in the meantime?

I have made an SQL script by hand, which drops indexes, alter columns to be SPARSE and re-adds indexes because you cannot alter a column to be SPARSE if there's an index, so it could be rather convenient with up-front support for SPARSE so I can get rid of this script.

@ajcvickers
Copy link
Member

@henrikdahl8240 This issue is in the Backlog milestone. This means that it is not planned for the next release (EF Core 5.0). We will re-assess the backlog following the this release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.

@roji
Copy link
Member

roji commented May 9, 2020

Note: as mentioned by @henrikdahl8240 in #20880 (comment), SPARSE columns could be a good fit for TPH.

@jonlouie
Copy link
Contributor

@ajcvickers Is the EF Core team still open to accepting a solution from the community? If so, I'd like to spend a few more days preparing a PR for review.

With the help of the prior discussions in this issue, I was able to locate most places that will require code changes and spent some time getting familiar with PropertyBuilder's and MigrationsSQLGenerator's. Please let me know if you have any suggestions and/or if I should put a hold on this effort.

@ajcvickers
Copy link
Member

@jonlouie Yes, still interested, and I don't think there is any reason to put it on hold. :-)

@eugbaranov
Copy link

@jonlouie, just wondering if you had any luck with preparing PR for this?

@jonlouie
Copy link
Contributor

@eugbaranov Unfortunately, I did not end finding the time to complete my PR. If you are looking to pick up this issue, here are some places that likely need modifications or additions:

  • src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs
  • src/EFCore.SqlServer/Extensions/SqlServerPropertyExtensions.cs
  • src/EFCore.SqlServer/Internal/SqlServerModelValidator.cs
  • src/EFCore.SqlServer/Metadata/Internal/SqlServerAnnotationNames.cs
  • src/EFCore.SqlServer/Metadata/Internal/SqlServerAnnotationProvider.cs
  • src/EFCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs

@roji roji changed the title SqlServer: Fluent API to configure a column as SPARSE column Support for SQL Server sparse columns Jan 16, 2021
roji added a commit that referenced this issue Jan 16, 2021
@roji roji self-assigned this Jan 16, 2021
@roji roji modified the milestones: Backlog, 6.0.0 Jan 16, 2021
@roji roji added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed good first issue This issue should be relatively straightforward to fix. labels Jan 16, 2021
roji added a commit that referenced this issue Jan 16, 2021
roji added a commit that referenced this issue Jan 21, 2021
roji added a commit that referenced this issue Jan 21, 2021
@ghost ghost closed this as completed in #23904 Jan 22, 2021
ghost pushed a commit that referenced this issue Jan 22, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0, 6.0.0-preview1 Jan 27, 2021
@ajcvickers ajcvickers modified the milestones: 6.0.0-preview1, 6.0.0 Nov 8, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migrations 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.