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