Search Results for

    Interface ISeedProfile<T>

    A reusable, named bundle of seed data that can be applied to any DbContextBuilder<T> in a single call via UseSeedProfile(ISeedProfile<T>).

    Namespace: Wolfgang.DbContextBuilderCore
    Assembly: Wolfgang.DbContextBuilder-Core.dll
    Syntax
    public interface ISeedProfile<T> where T : DbContext
    Type Parameters
    Name Description
    T

    The DbContext type the profile seeds.

    Remarks

    Seed profiles encapsulate a complete set of seed entities so the same setup can be shared across many test classes instead of being re-built in each one. Implement Apply(DbContextBuilder<T>) to call SeedWith one or more times on the supplied builder.

    Examples
    public sealed class StandardCatalogue : ISeedProfile<ShopDbContext>
    {
        public void Apply(DbContextBuilder<ShopDbContext> builder) =>
            builder.SeedWith(
                new Product { Name = "Widget" },
                new Product { Name = "Gadget" });
    }
    
    await using var context = await new DbContextBuilder<ShopDbContext>()
        .UseInMemory()
        .UseSeedProfile(new StandardCatalogue())
        .BuildAsync();

    Methods

    | Edit this page View Source

    Apply(DbContextBuilder<T>)

    Applies this profile's seed data to builder, typically by calling SeedWith one or more times.

    Declaration
    void Apply(DbContextBuilder<T> builder)
    Parameters
    Type Name Description
    DbContextBuilder<T> builder

    The builder to seed.

    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX