Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

DbContextOptionsBuilder.UseSeeding(Action<DbContext,Boolean>) Method

Definition

Namespace:
Microsoft.EntityFrameworkCore
Assembly:
Microsoft.EntityFrameworkCore.dll
Package:
Microsoft.EntityFrameworkCore v10.0.0
Package:
Microsoft.EntityFrameworkCore v9.0.0
Source:
DbContextOptionsBuilder.cs
Source:
DbContextOptionsBuilder.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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 UseSeeding(Action<Microsoft.EntityFrameworkCore.DbContext,bool> seed);
abstract member UseSeeding : Action<Microsoft.EntityFrameworkCore.DbContext, bool> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
override this.UseSeeding : Action<Microsoft.EntityFrameworkCore.DbContext, bool> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
Public Overridable Function UseSeeding (seed As Action(Of DbContext, Boolean)) As DbContextOptionsBuilder

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


Feedback

Was this page helpful?