Share via


DbContextOptionsBuilder<TContext>.UseSeeding Method

Definition

Overloads

UseSeeding(Action<DbContext,Boolean>)

Configures the seed method to run after EnsureCreated() is called or after migrations are applied. It will be invoked even if no changes to the store were performed.

UseSeeding(Action<TContext,Boolean>)

Configures the seed method to run after EnsureCreated() is called or after migrations are applied. It will be invoked even if no changes to the store were performed.

UseSeeding(Action<DbContext,Boolean>)

Source:
DbContextOptionsBuilder%60.cs

Configures the seed method to run after EnsureCreated() is called or after migrations are applied. It will be invoked even if no changes to the store were performed.

public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseSeeding (Action<Microsoft.EntityFrameworkCore.DbContext,bool> seed);
override this.UseSeeding : Action<Microsoft.EntityFrameworkCore.DbContext, bool> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)>
Public Overridable Function UseSeeding (seed As Action(Of DbContext, Boolean)) As DbContextOptionsBuilder(Of TContext)

Parameters

seed
Action<DbContext,Boolean>

The seed method to run.

Returns

The same builder instance so that multiple calls can be chained.

Remarks

The bool argument of the seed delegate indicates whether any store management operation was performed.

It is recomended to also call UseAsyncSeeding(Func<DbContext,Boolean,CancellationToken,Task>) with the same logic.

See Using DbContextOptions for more information and examples.

Applies to

UseSeeding(Action<TContext,Boolean>)

Source:
DbContextOptionsBuilder%60.cs

Configures the seed method to run after EnsureCreated() is called or after migrations are applied. It will be invoked even if no changes to the store were performed.

public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseSeeding (Action<TContext,bool> seed);
override this.UseSeeding : Action<'Context, bool (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)>
Public Overridable Function UseSeeding (seed As Action(Of TContext, Boolean)) As DbContextOptionsBuilder(Of TContext)

Parameters

seed
Action<TContext,Boolean>

The seed method to run.

Returns

The same builder instance so that multiple calls can be chained.

Remarks

The bool argument of the seed delegate indicates whether any store management operation was performed.

It is recomended to also call UseAsyncSeeding(Func<TContext,Boolean,CancellationToken,Task>) with the same logic.

See Using DbContextOptions for more information and examples.

Applies to