ProtoTest.Sql.EntityFrameworkCore
1.0.1
dotnet add package ProtoTest.Sql.EntityFrameworkCore --version 1.0.1
NuGet\Install-Package ProtoTest.Sql.EntityFrameworkCore -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ProtoTest.Sql.EntityFrameworkCore" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ProtoTest.Sql.EntityFrameworkCore" Version="1.0.1" />
<PackageReference Include="ProtoTest.Sql.EntityFrameworkCore" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ProtoTest.Sql.EntityFrameworkCore --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ProtoTest.Sql.EntityFrameworkCore, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ProtoTest.Sql.EntityFrameworkCore@1.0.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ProtoTest.Sql.EntityFrameworkCore&version=1.0.1
#tool nuget:?package=ProtoTest.Sql.EntityFrameworkCore&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
ProtoTest.Sql.EntityFrameworkCore
Entity Framework Core over the per-test connection, enlisted in its transaction.
dotnet add package ProtoTest.Sql.EntityFrameworkCore
Quick start
builder
.AddSql(_ => new NpgsqlConnection(connectionString))
.AddEntityFrameworkCore<OrdersDbContext>((services, options) =>
options.UseNpgsql(services.GetRequiredService<DbConnection>()));
[ProtoTest]
public async Task Order_ShouldPersistThroughTheContext()
{
var context = Proto.Context.Sql<OrdersDbContext>();
context.Orders.Add(new Order { Reference = "ORD-1" });
await context.SaveChangesAsync();
}
What it adds
- Registration —
AddEntityFrameworkCore<TContext>((services, options) => …)registers the scoped context over the test connection and aSqlEnlistmentHook<TContext>, and adds theEntity Framework Corecapability (store). - Accessor —
Proto.Context.Sql<TContext>()resolves the scoped context from dependency injection. - Enlistment — with transactional isolation the hook calls
UseTransaction(session.Transaction)and recordssql.enlist; withSqlIsolation.Noneit only validates the connection. - Repeats — a second registration for the same
TContextis a no-op; a different context type is its own registration. - Capability — registers
Entity Framework Core(store), so[RequiresCapability(ProtoCapabilityKinds.Store, CapabilityName = "Entity Framework Core")]proves composition. - Tracing —
sql.enlistrecords the enlistment withdb.context; individual commands are never traced.
Call order matters: the context must be configured with the test's DbConnection, and because EF Core keeps only the first DbContextOptions<TContext>, an AddDbContext call made after AddEntityFrameworkCore has its options dropped. The package has no options type or configuration section of its own; connection and isolation come from ProtoTest.Sql.
Learn more
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.12)
- ProtoTest.Core (>= 1.0.1)
- ProtoTest.Sql (>= 1.0.1)
-
net8.0
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.31)
- ProtoTest.Core (>= 1.0.1)
- ProtoTest.Sql (>= 1.0.1)
-
net9.0
- Microsoft.EntityFrameworkCore.Relational (>= 9.0.20)
- ProtoTest.Core (>= 1.0.1)
- ProtoTest.Sql (>= 1.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.