-
Notifications
You must be signed in to change notification settings - Fork 8
Upgrade to .NET 10.0 and update NuGet packages #823
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
69f906d
5c0a65a
a367dc9
0924c9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,22 +16,33 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) | |||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| builder.ConfigureServices(services => | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| ServiceDescriptor? descriptor = services.SingleOrDefault( | ||||||||||||||||||||||||||||||
| d => d.ServiceType == | ||||||||||||||||||||||||||||||
| typeof(DbContextOptions<EssentialCSharpWebContext>)); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // Remove the existing DbContext and related services | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| // Remove the existing DbContext and related services | |
| // Remove the primary DbContextOptions registration for EssentialCSharpWebContext |
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The filtering logic using Name.Contains("DbContextOptions") is fragile and could inadvertently remove services unrelated to EF Core. This string-based matching could match types that happen to have "DbContextOptions" in their name. Consider a more precise approach such as checking for specific known types like DbContextOptions<TContext>, IDbContextOptions, or filtering by namespace (e.g., types from Microsoft.EntityFrameworkCore).
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "Add SQLite DbContext without using the global service provider" but the code in lines 47-52 still uses BuildServiceProvider() to create a service provider and initialize the database. The comment may be misleading - consider clarifying that this refers to the DbContext options not using a cached/global service provider, while database initialization still requires building a temporary service provider.
Copilot
AI
Dec 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment states "Disable service provider caching to avoid shared state in EF Core 10" but doesn't explain why this is necessary or the implications. Consider expanding this comment to explain the specific EF Core 10 behavior change that necessitates this workaround, and any potential performance impact of disabling caching.
| // Disable service provider caching to avoid shared state in EF Core 10 | |
| // EF Core 10 change: DbContextOptions now participate more aggressively in internal | |
| // service provider caching so that model- and provider-specific services can be reused | |
| // across contexts. In this test setup we create many WebApplicationFactory instances that | |
| // all share the same in-memory SQLite connection. If EF Core caches the internal service | |
| // provider globally, state for one test run (e.g., model metadata, conventions, and | |
| // provider services) can be reused by another, causing "multiple providers" errors and | |
| // flaky tests due to unexpected shared state between factories. | |
| // | |
| // Disabling service provider caching forces EF Core to build a fresh internal service | |
| // provider for each DbContextOptions instance, isolating tests at the cost of a small | |
| // per-context startup overhead. This trade-off is acceptable for integration tests, but | |
| // should generally be avoided in production code where the additional allocations and | |
| // startup cost could impact performance. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| { | ||
| "sdk": { | ||
| "version": "9.0.101", | ||
| "version": "10.0.100", | ||
| "rollForward": "latestMinor" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a367dc9. Removed the NU1902/NU1903 suppressions from this file and moved them to Directory.Build.props using WarningsNotAsErrors instead.