Sdílet prostřednictvím


DbContextOptionsBuilder<TContext>.UseAsyncSeeding Method

Definition

Overloads

UseAsyncSeeding(Func<DbContext,Boolean,CancellationToken,Task>)

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

UseAsyncSeeding(Func<TContext,Boolean,CancellationToken,Task>)

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

UseAsyncSeeding(Func<DbContext,Boolean,CancellationToken,Task>)

Source:
DbContextOptionsBuilder%60.cs

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

public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseAsyncSeeding (Func<Microsoft.EntityFrameworkCore.DbContext,bool,System.Threading.CancellationToken,System.Threading.Tasks.Task> seedAsync);
override this.UseAsyncSeeding : Func<Microsoft.EntityFrameworkCore.DbContext, bool, System.Threading.CancellationToken, System.Threading.Tasks.Task> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)>
Public Overridable Function UseAsyncSeeding (seedAsync As Func(Of DbContext, Boolean, CancellationToken, Task)) As DbContextOptionsBuilder(Of TContext)

Parameters

seedAsync
Func<DbContext,Boolean,CancellationToken,Task>

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 UseSeeding(Action<DbContext,Boolean>) with the same logic.

See Using DbContextOptions for more information and examples.

Applies to

UseAsyncSeeding(Func<TContext,Boolean,CancellationToken,Task>)

Source:
DbContextOptionsBuilder%60.cs

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

public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseAsyncSeeding (Func<TContext,bool,System.Threading.CancellationToken,System.Threading.Tasks.Task> seedAsync);
override this.UseAsyncSeeding : Func<'Context, bool, System.Threading.CancellationToken, System.Threading.Tasks.Task (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)>
Public Overridable Function UseAsyncSeeding (seedAsync As Func(Of TContext, Boolean, CancellationToken, Task)) As DbContextOptionsBuilder(Of TContext)

Parameters

seedAsync
Func<TContext,Boolean,CancellationToken,Task>

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 UseSeeding(Action<TContext,Boolean>) with the same logic.

See Using DbContextOptions for more information and examples.

Applies to