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

Stop scaffolding DbSet initialization to null! #26877

Closed
Tracked by #22948
roji opened this issue Dec 2, 2021 · 3 comments · Fixed by #28684
Closed
Tracked by #22948

Stop scaffolding DbSet initialization to null! #26877

roji opened this issue Dec 2, 2021 · 3 comments · Fixed by #28684
Assignees
Labels
area-scaffolding closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@roji
Copy link
Member

roji commented Dec 2, 2021

Now that we have a diagnostics suppressor for uninitialized DbSet properties (#26795), we can stop scaffolding DbContext code which initializes DbSet properties to null!.

@roji
Copy link
Member Author

roji commented Apr 22, 2022

After #27869 we should properly suppress all uninitialized DbSet warnings.

However, for cases where a constructor exists on the DbContext, our new suppressor depends on a new Roslyn enhancement added in 7.0.0-preview3 (dotnet/roslyn#58073). This means that when using an older SDK, those specific warnings would not be suppressed.

This isn't a big problem in itself (not worse than today), but could be an issue if we change scaffolding to remove the bang initialization (this issue); if EF Core 7.0 will target .NET 6.0 as it does today, it would be usable with SDK 6.0 as well, where the scaffolded code would start generate a warning.

@roji roji removed this from the 7.0.0 milestone Apr 22, 2022
@ajcvickers ajcvickers added this to the Backlog milestone Apr 28, 2022
@bricelam bricelam removed this from the Backlog milestone Jul 22, 2022
@ajcvickers ajcvickers changed the title Stop scaffolding DbSet initialization to null! Stop scaffolding DbSet initialization to null! Jul 27, 2022
@ajcvickers ajcvickers added this to the 7.0.0 milestone Jul 28, 2022
@ajcvickers
Copy link
Member

Note from triage: looks like an issue with analyzers during tests. @roji will investigate.

@roji
Copy link
Member Author

roji commented Aug 1, 2022

@bricelam I did some trivial testing from a console program against 7.0.0-preview.6, and everything seems to be working correctly - I'm getting no uninitialized warnings for DbSets (with a DbContext, constructor or without it). So I guess there's some testing issue there - if you want to point me to some failing test I can look...

@bricelam bricelam self-assigned this Aug 1, 2022
bricelam added a commit to bricelam/efcore that referenced this issue Aug 11, 2022
@bricelam bricelam added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels Aug 25, 2022
bricelam added a commit to bricelam/efcore that referenced this issue Aug 29, 2022
@bricelam bricelam added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Aug 29, 2022
@bricelam bricelam modified the milestones: 7.0.0, 7.0.0-rc2 Aug 29, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-rc2, 7.0.0 Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-scaffolding closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants