You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Stop scaffolding DbSet initialization to null! #26877
Now that we have a diagnostics suppressor for uninitialized DbSet properties (#26795), we can stop scaffolding DbContext code which initializes DbSet properties to null!.
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.
@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...
Activity
roji commentedon 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.
[-]Stop scaffolding DbSet initialization to null![/-][+]Stop scaffolding DbSet initialization to `null!`[/+]ajcvickers commentedon Jul 28, 2022
Note from triage: looks like an issue with analyzers during tests. @roji will investigate.
roji commentedon 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...
Stop scaffolding DbSet initializers
Stop scaffolding DbSet initializers
Stop scaffolding DbSet initializers