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" />
                    
Directory.Packages.props
<PackageReference Include="ProtoTest.Sql.EntityFrameworkCore" />
                    
Project file
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
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=ProtoTest.Sql.EntityFrameworkCore&version=1.0.1
                    
Install as a Cake Tool

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 a SqlEnlistmentHook<TContext>, and adds the Entity Framework Core capability (store).
  • Accessor — Proto.Context.Sql<TContext>() resolves the scoped context from dependency injection.
  • Enlistment — with transactional isolation the hook calls UseTransaction(session.Transaction) and records sql.enlist; with SqlIsolation.None it only validates the connection.
  • Repeats — a second registration for the same TContext is 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.enlist records the enlistment with db.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 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.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 82 9/20/2026
1.0.0 85 9/20/2026