Learn Entity Framework Core: https://www.learnentityframeworkcore.com/
Entity Framework Core Tutorial: https://entityframeworkcore.com/
Entity Framework 6 Tutorial: https://entityframework.net/
Info
Version: | 2.0.0 |
Author(s): | TheArchitectDev, Timovzl |
Last Update: | Thursday, March 23, 2023 |
.NET Fiddle: | Create the first Fiddle |
NuGet Url: | https://www.nuget.org/packages/Architect.EntityFramework.DbContextManagement |
Install
Install-Package Architect.EntityFramework.DbContextManagement
dotnet add package Architect.EntityFramework.DbContextManagement
paket add Architect.EntityFramework.DbContextManagement
Architect.EntityFramework.DbContextManagement Download (Unzip the "nupkg" after downloading)
Dependencies
- Architect.AmbientContexts(>= 1.0.0)
- Microsoft.EntityFrameworkCore(>= 5.0.0)
- Microsoft.EntityFrameworkCore.Relational(>= 5.0.0)
Tags
The persistence or infrastructure layer uses the DbContext (e.g.
from a repository). Controlling its scope and transaction lifetime, however, is ideally the reponsibility of the orchestrating layer (e.g. from an application service). This package adds that ability to Entity Framework Core 5.0.0 and up.
https://github.com/TheArchitectDev/Architect.EntityFramework.DbContextManagement
Release notes:
2.0.0:
- BREAKING: Now using AmbientContexts 2.0.0.
- Semi-breaking: Failure on commit (extremely rare) now throws IOException instead of Exception.
- Added static DbContextScope<TDbContext>.HasDbContext, to match the feature set of IDbContextAccessor.
- Retries now ensure that the connection is closed before retrying, to avoid the risk of leaking session state.
(As with EF's DbContext disposal in general, this relies on the database provider's connection reset.)
- Scoped execution now protects against dangerous "failure on commit" retries even on manual commits (rather than just on IExecutionScope's implicit commit).
- Worked around an EF bug where the DbContext would obscure the exception caused by a broken model behind an ObjectDisposedException, even though DbContext._disposed=false.
- Scoped execution: Fixed a bug where the exception caused by a broken model would be obscured behind a wrongful IncompatibleVersionException.
- MockDbContextProvider: Fixed a bug where nested scopes would not work as expected.
- MockDbContextProvider: Fixed a bug where soft attempts to roll back a transaction when there was none could cause an unintended TransactionAbortedException.
1.0.1:
- Now using AmbientContexts 1.1.1, which fixes extremely rare bugs and improves performance.