Class ProtoHostBuilderExtensions
- Namespace
- ProtoTest.Sql.EntityFrameworkCore
- Assembly
- ProtoTest.Sql.EntityFrameworkCore.dll
public static class ProtoHostBuilderExtensions
- Inheritance
-
ProtoHostBuilderExtensions
- Inherited Members
Methods
AddEntityFrameworkCore<TContext>(IProtoHostBuilder, Action<IServiceProvider, DbContextOptionsBuilder>)
Registers a TContext for every test, built over the connection
ProtoTest.Sql owns. Configure the provider with that connection - for example
options.UseNpgsql(services.GetRequiredService<DbConnection>()) - so the test's
transaction covers both Entity Framework Core and raw commands. A second registration for the same
context is a no-op; two different contexts are different registrations and both apply. A context the
host registered before this call keeps the host's configuration but is still enlisted in the test's
transaction; Entity Framework Core keeps only the first options registration, so a host
AddDbContext called after this one has its options delegate dropped and the host's context
must be registered first.
public static IProtoHostBuilder AddEntityFrameworkCore<TContext>(this IProtoHostBuilder builder, Action<IServiceProvider, DbContextOptionsBuilder> configure) where TContext : DbContext
Parameters
builderIProtoHostBuilderconfigureAction<IServiceProvider, DbContextOptionsBuilder>
Returns
Type Parameters
TContext
Remarks
The Entity Framework Core store capability follows the SQL address rule: when
AddSql declared AddressKeys and none can provide a
connection, the capability is absent, gated tests skip, and the enlistment hook stays out of the
context and the session instead of opening a connection ProtoTest does not own. The keys are read
when this call runs, so call it after AddSql; without declared keys (or without a preceding
AddSql) the capability stays unconditional, as before.