Skip to content

Stop scaffolding DbSet initialization to null! #26877

Description

@roji

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

Activity

  1. added this to the 7.0.0 milestone on Dec 2, 2021
  2. self-assigned this
    on Dec 2, 2021
  3. self-assigned this
    on Feb 10, 2022
  4. roji commented on Apr 22, 2022

    @roji
    MemberAuthor

    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.

  5. removed this from the 7.0.0 milestone on Apr 22, 2022
  6. added this to the Backlog milestone on Apr 28, 2022
  7. removed this from the Backlog milestone on Jul 22, 2022
  8. changed the title [-]Stop scaffolding DbSet initialization to null![/-] [+]Stop scaffolding DbSet initialization to `null!`[/+] on Jul 27, 2022
  9. added this to the 7.0.0 milestone on Jul 28, 2022
  10. ajcvickers commented on Jul 28, 2022

    @ajcvickers
    Contributor

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

  11. roji commented on Aug 1, 2022

    @roji
    MemberAuthor

    @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...

  12. self-assigned this
    on Aug 1, 2022
  13. added a commit that references this issue on Aug 11, 2022
    0e5c831
  14. added a commit that references this issue on Aug 29, 2022
    9bcd2de
  15. modified the milestones: 7.0.0, on Aug 29, 2022
  16. added a commit that references this issue on Aug 29, 2022
    d144ec6
  17. modified the milestones: , 7.0.0 on Nov 5, 2022
  18. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions