Open PeterKMX opened 1 month ago
@PeterKMX the EF docs do assume certain basic knowledge of C# and .NET, such as how IDisposable works and the using
statement; having to explain basic C# concepts everywhere in our docs would make them very unwieldy and hostile to people who already know C#.
Type of issue
Missing information
Description
Hi, I am new to EF Core and I have a comment about this part about DbContext (of the page with URL provides below)
" ... public void DoSomething() { using (var context = _contextFactory.CreateDbContext()) { // ... } }
Notice that the DbContext instances created in this way are not managed by the application's service provider and therefore must be disposed by the application. ..."
My interpretation is that the using statement above will take care for correctly disposing the created context object. However, it makes me think that I should implement the Dispose pattern. Therefore I suggest to improve this part to avoid possible confusion for less experienced developers. If my assumption is correct, I would rather say something along this line (?):
"... Notice that the using statement above also disposes the created instance. This is necessary since DbContext instances created this way are not managed by the application's service provider and therefore must be disposed by the application. ..."
Best regards,
Page URL
https://learn.microsoft.com/en-us/ef/core/dbcontext-configuration/
Content source URL
https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/dbcontext-configuration/index.md
Document Version Independent Id
b0a3d5ad-b62c-1ff4-386a-f11e350eea0c
Article author
@ajcvickers